服务器脚本搭建国基北盛openstack平台

@

基础环境搭建

环境准备:
1,使用两台服务器分别作为控制节点,和计算节点,密码为000000
2,使用crt上传镜像CentOS-7-x86_64-DVD-1804.iso 和chinaskills_cloud_iaas.iso到控制节点root目录下

控制节点网卡配置

cat /etc/sysconfig/network-scripts/ifcfg-enp2s0f0

PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp2s0f0                                     #第一张网卡
UUID=bf67ee4d-f110-407f-bc74-b51b755650b6
DEVICE=enp2s0f0
ONBOOT=yes
IPADDR=10.60.2.10
PREFIX=24                                    #子网掩码24,和NETMASK一样的用法
GATEWAY=10.60.2.1

[root@controller ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp2s0f1
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp2s0f1                                    #第二张网卡
UUID=986557de-f9d3-4554-af06-cb057dfce365
DEVICE=enp2s0f1
ONBOOT=yes
IPADDR=10.60.3.10
PREFIX=24                                #注意第二张网卡不要配置网关 

计算节点网卡配置

cat /etc/sysconfig/network-scripts/ifcfg-enp2s0f0

PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp2s0f0
UUID=5871f25a-3b4e-40c1-b266-043d6604da66
DEVICE=enp2s0f0
ONBOOT=yes
IPADDR=10.60.2.20
PREFIX=24
GATEWAY=10.60.2.1

[root@compute ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp2s0f1
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp2s0f1
UUID=a4097286-851d-4364-8d63-ce6a4e4227a2
DEVICE=enp2s0f1
ONBOOT=yes
IPADDR=10.60.3.20
PREFIX=24      

两边网卡配置完成后重启
注:其实第二张网卡可以不用配置,在neutron脚本会被修改,但是第二张网卡的网段要知道,是要用于后面云主机实例的外网卡的!

主机映射

vi /etc/hosts

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.60.2.10 controller
10.60.2.20 compute      #注意主机名要在IP地址的后面

用scp命令远程传输给compute节点

scp /etc/hosts compute:/etc/hosts

3,关闭防火墙和selinux以及NetworkManager

关闭防火墙并设置开机不启动

systemctl stop firewalld && systemctl enable firewalld

关闭NetworkManager并设置开机不启动

systemctl stop NetworkManager && systemctl enable NetworkManager

临时关闭Selinux

setenforce 0

这几步后面执行pre脚本时会再做一遍的

设置yum源

创建挂载目录

mkdir /opt/

挂载yum源到/mnt/目录下再复制到/opt/下做永久挂载,也可以yum直接挂载到/opt/下

[root@controller ~]# mount /root/CentOS-7-x86_64-DVD-1804.iso /mnt
[root@controller ~]# cp -rfv /mnt/* /opt/centos
[root@controller ~]# umount /mnt/
[root@controller ~]# mount /root/chinaskills_cloud_iaas.iso /mnt
[root@controller ~]# cp -rfv /mnt/* /opt/iaas
[root@controller ~]# umount /mnt/

删除原有yum源

rm -rf /etc/yum.repos.d/*

编写yum文件

vi /etc/yum.repos.d/ftp.repo

[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=file:///opt/iaas/iaas-repo
gpgcheck=0
enabled=1

使用ftp作为远程共享

yum install -y vsftpd

在/etc/vsftpd/vsftpd.conf/下配置文件

[root@controller ~]# cat /etc/vsftpd/vsftpd.conf 
# Example config file /etc/vsftpd/vsftpd.conf
anon_root=/opt    #表示远程共享此节点/opt/下目录

删除compute节点原有yum源并将编写的yum文件远程传输

[root@compute ~]# rm -rf /etc/yum.repos.d/*
[root@controller ~]# scp /etc/yum.repos.d/ftp.repo compute:/etc/yum.repos.d/
[root@compute ~]# cat /etc/yum.repos.d/ftp.repo 
[centos]
name=centos
baseurl=ftp://controller/centos   #记得修改
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=ftp://controller/iaas/iaas-repo   #记得修改
gpgcheck=0
enabled=1

验证yum源是否挂载成功

[root@controller ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: centos iaas
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@controller ~]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
centos                                                                                                                    | 3.6 kB  00:00:00     
iaas                                                                                                                      | 2.9 kB  00:00:00     
(1/3): centos/group_gz                                                                                                    | 166 kB  00:00:00     
(2/3): iaas/primary_db                                                                                                    | 1.4 MB  00:00:00     
(3/3): centos/primary_db                                                                                                  | 3.1 MB  00:00:00     
repo id                                                               repo name                                                            status
centos                                                                centos                                                               3,971
iaas                                                                  iaas                                                                 3,232
repolist: 7,203

[root@compute ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: centos iaas
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@compute ~]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
centos                                                                                                                    | 3.6 kB  00:00:00     
iaas                                                                                                                      | 2.9 kB  00:00:00     
(1/3): centos/group_gz                                                                                                    | 166 kB  00:00:00     
(2/3): iaas/primary_db                                                                                                    | 1.4 MB  00:00:00     
(3/3): centos/primary_db                                                                                                  | 3.1 MB  00:00:00     
repo id                                                               repo name                                                            status
centos                                                                centos                                                               3,971
iaas                                                                  iaas                                                                 3,232
repolist: 7,203

计算节点分区

使用fdisk命令在计算节点分出两块硬盘提供给cinder和swift使用

[root@compute ~]# lsblk
NAME              MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                 8:0    0   2.7T  0 disk 
├─sda1              8:1    0     2M  0 part 
├─sda2              8:2    0     1G  0 part /boot
├─sda3              8:3    0 716.8G  0 part 
├─sda4              8:4    0     1T  0 part 
├─sda5              8:5    0   100G  0 part 
├─sda6              8:6    0    27G  0 part 
├─sda7              8:7    0     1G  0 part 
└─sda8              8:8    0   865G  0 part 
  ├─centos02-root 253:0    0    50G  0 lvm  /
  └─centos02-swap 253:3    0     4G  0 lvm  [SWAP]
sdb                 8:16   0   890G  0 disk 
├─sdb1              8:17   0   100G  0 part    #在openrc.sh环境变量中提供给cinder
└─sdb2              8:18   0   100G  0 part    #在openrc.sh环境变量中提供给swift

配置openrc.sh环境变量

yum install -y iaas-xiandian

[root@controller ~]# cat /etc/xiandian/openrc.sh 
HOST_IP=10.60.2.10 
HOST_PASS=000000    #控制节点密码,注意不要输错
HOST_NAME=controller
HOST_IP_NODE=10.60.2.20
HOST_PASS_NODE=000000   #计算节点密码
HOST_NAME_NODE=compute
network_segment_IP=10.60.2.0/24
RABBIT_USER=openstack
RABBIT_PASS=000000
DB_PASS=000000
DOMAIN_NAME=demo
ADMIN_PASS=000000
DEMO_PASS=000000
KEYSTONE_DBPASS=000000
GLANCE_DBPASS=000000
GLANCE_PASS=000000
NOVA_DBPASS=000000
NOVA_PASS=000000
NEUTRON_DBPASS=000000
NEUTRON_PASS=000000
METADATA_SECRET=000000
INTERFACE_IP=10.60.2.10   #千万注意在那个节点就输入那个节点的地址,等下远程传到计算节点注意更改
INTERFACE_NAME=enp2s0f1   #第二张网卡
Physical_NAME=provider
minvlan=101
maxvlan=200
CINDER_DBPASS=000000
CINDER_PASS=000000
BLOCK_DISK=sdb1   #提供给cinder的
SWIFT_PASS=000000
OBJECT_DISK=sdb2  #提供给swift的
STORAGE_LOCAL_NET_IP=10.60.2.20    #第二张网卡IP
HEAT_DBPASS=000000
HEAT_PASS=000000
ZUN_DBPASS=000000
ZUN_PASS=000000
KURYR_DBPASS=000000
KURYR_PASS=000000
CEILOMETER_DBPASS=000000
CEILOMETER_PASS=000000
AODH_DBPASS=000000
AODH_PASS=000000
BARBICAN_DBPASS=000000
BARBICAN_PASS=000000

远程传输给compute

scp /etc/xiandian/openrc.sh compute:/etc/xiandian/openrc.sh

注意修改INTERFACE_IP=10.60.2.20

平台组件搭建

controller和compute同时执行,然后Crtl+D刷新,千万要执行

iaas-pre-host.sh

controller节点执行

iaas-install-mysql.sh
iaas-install-keystione.sh
iaas-install-glance.sh
iaas-install-nova-controller.sh
iaas-install-neutron-controller.sh
iaas-install-dashboard.sh

compute节点执行

iaas-install-nova-compute.sh
iaas-install-neutron-compute.sh

后面的cinder,swift组件可以根据需要再进行搭建,跑完compute脚本后http://ip/dashboard访问dashboard平台

posted @ 2022-04-27 12:07  huhy  阅读(789)  评论(0编辑  收藏  举报