前期准备与说明

使用搭建 OpenStack 私有云平台的软件:VMware Workstation 16 Pro
使用的基础镜像:CentOS-7-x86_64-DVD-1804.iso
使用搭建的ISO镜像包:ChinaSkills_Cloud_IaaS.iso

网卡配置

仅主机网卡

image-20220828202322395

NAT网卡

image-20220828202610199

硬件配置

controller

image-20220828205606881

compute

image-20220828205759149

各节点IP地址

主机名 仅主机网卡 NAT网卡
controller IP: 172.16.10.10 IP: 10.0.0.0/24
网关: 10.0.0.1
compute IP: 172.16.10.20 IP: 10.0.0.0/24
网关: 10.0.0.1

初始化配置

controllercompute

[root@controller ~]# systemctl stop firewalld && systemctl disable firewalld
[root@controller ~]# vi /etc/selinux/config
#修改
SELINUX=permissive

[root@controller ~]# setenforce 0
[root@controller ~]# vi /etc/hosts
#底部添加
172.16.10.10	controller
172.16.10.20	compute
[root@compute ~]# systemctl stop firewalld && systemctl disable firewalld
[root@compute ~]# vi /etc/selinux/config
#修改
SELINUX=permissive

[root@compute ~]# setenforce 0
[root@compute ~]# vi /etc/hosts
#底部添加
172.16.10.10	controller
172.16.10.20	compute

上传所需镜像文件

使用 FileZilla 上传至 /root 目录,或使用光盘挂载进虚拟机

[root@controller ~]# ll
-rw-r--r--. 1 root root 4470079488 Aug 28 21:00 CentOS-7-x86_64-DVD-1804.iso
-rw-r--r--. 1 root root 3799093248 Aug 28 21:00 ChinaSkills_Cloud_IaaS.iso
[root@controller ~]# mkdir /opt/{centos,openstack}

[root@controller ~]# mount -o loop CentOS-7-x86_64-DVD-1804.iso /mnt/
mount: /dev/loop0 is write-protected, mounting read-only
[root@controller ~]# cp -rf /mnt/* /opt/centos/
[root@controller ~]# umount /mnt/

[root@controller ~]# mount -o loop ChinaSkills_Cloud_IaaS.iso /mnt/
mount: /dev/loop0 is write-protected, mounting read-only
[root@controller ~]# cp -rf /mnt/* /opt/openstack/
[root@controller ~]# umount /mnt/

配置本地yum源

[root@controller ~]# cd /etc/yum.repos.d/
[root@controller yum.repos.d]# rm -rf *.repo
[root@controller yum.repos.d]# vi local.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[openstack]
name=openstack
baseurl=file:///opt/openstack/iaas-repo
gpgcheck=0
enabled=1

[root@controller ~]# yum repolist
repo id			repo name		status
!centos			centos			3,971
!openstack		openstack		3,232
repolist: 7,203

安装HTTP服务

[root@controller ~]# yum install -y httpd
[root@controller ~]# systemctl start httpd && systemctl enable httpd
[root@controller ~]# ln -s /opt/ /var/www/html/
[root@controller ~]# ll /var/www/html/
total 0
lrwxrwxrwx 1 root root 5 Aug 28 21:10 opt -> /opt/

配置网络yum源

[root@compute ~]# cd /etc/yum.repos.d/
[root@compute yum.repos.d]# rm -rf *.repo
[root@compute yum.repos.d]# vi http.repo
[centos]
name=centos
baseurl=http://172.16.10.10/opt/centos
gpgcheck=0
enabled=1
[openstack]
name=openstack
baseurl=http://172.16.10.10/opt/openstack/iaas-repo
gpgcheck=0
enabled=1

[root@compute ~]# yum repolist
repo id			repo name		status
!centos			centos			3,971
!openstack		openstack		3,232
repolist: 7,203

搭建云平台

安装先电软件包

[root@controller ~]# yum install -y iaas-xiandian
[root@compute ~]# yum install -y iaas-xiandian

[root@controller ~]# vi /etc/xiandian/openrc.sh
在命令模式下执行	:%s/^.//g	用于删除首行井号
在命令模式下执行	:%s/PASS=/PASS=000000/g		用于编写PASS

#--------------------system Config--------------------##
#Controller Server Manager IP. example:x.x.x.x
HOST_IP=172.16.10.10

#Controller HOST Password. example:000000
HOST_PASS=000000

#Controller Server hostname. example:controller
HOST_NAME=controller

#Compute Node Manager IP. example:x.x.x.x
HOST_IP_NODE=172.16.10.20

#Compute HOST Password. example:000000
HOST_PASS_NODE=000000

#Compute Node hostname. example:compute
HOST_NAME_NODE=compute

#--------------------Chrony Config-------------------##
#Controller network segment IP. example:x.x.0.0/16(x.x.x.0/24)
network_segment_IP=172.16.10.0/24

#--------------------Rabbit Config ------------------##
#user for rabbit. example:openstack
RABBIT_USER=openstack

#Password for rabbit user .example:000000
RABBIT_PASS=000000

#--------------------MySQL Config---------------------##
#Password for MySQL root user . exmaple:000000
DB_PASS=000000

#--------------------Keystone Config------------------##
#Password for Keystore admin user. exmaple:000000
DOMAIN_NAME=demo
ADMIN_PASS=000000
DEMO_PASS=000000

#Password for Mysql keystore user. exmaple:000000
KEYSTONE_DBPASS=000000

#--------------------Glance Config--------------------##
#Password for Mysql glance user. exmaple:000000
GLANCE_DBPASS=000000

#Password for Keystore glance user. exmaple:000000
GLANCE_PASS=000000

#--------------------Nova Config----------------------##
#Password for Mysql nova user. exmaple:000000
NOVA_DBPASS=000000

#Password for Keystore nova user. exmaple:000000
NOVA_PASS=000000

#--------------------Neturon Config-------------------##
#Password for Mysql neutron user. exmaple:000000
NEUTRON_DBPASS=000000

#Password for Keystore neutron user. exmaple:000000
NEUTRON_PASS=000000

#metadata secret for neutron. exmaple:000000
METADATA_SECRET=000000

#Tunnel Network Interface. example:x.x.x.x
INTERFACE_IP=172.16.10.10

#External Network Interface. example:eth1
INTERFACE_NAME=ens34

#External Network The Physical Adapter. example:provider
Physical_NAME=provider

#First Vlan ID in VLAN RANGE for VLAN Network. exmaple:101
minvlan=1

#Last Vlan ID in VLAN RANGE for VLAN Network. example:200
maxvlan=2000

#--------------------Cinder Config--------------------##
#Password for Mysql cinder user. exmaple:000000
CINDER_DBPASS=000000

#Password for Keystore cinder user. exmaple:000000
CINDER_PASS=000000

#Cinder Block Disk. example:md126p3
BLOCK_DISK=sdb

#--------------------Swift Config---------------------##
#Password for Keystore swift user. exmaple:000000
SWIFT_PASS=000000

#The NODE Object Disk for Swift. example:md126p4.
OBJECT_DISK=sdc

#The NODE IP for Swift Storage Network. example:x.x.x.x.
STORAGE_LOCAL_NET_IP=172.16.10.20

#--------------------Heat Config----------------------##
#Password for Mysql heat user. exmaple:000000
HEAT_DBPASS=000000

#Password for Keystore heat user. exmaple:000000
HEAT_PASS=000000

#--------------------Zun Config-----------------------##
#Password for Mysql Zun user. exmaple:000000
ZUN_DBPASS=000000

#Password for Keystore Zun user. exmaple:000000
ZUN_PASS=000000

#Password for Mysql Kuryr user. exmaple:000000
KURYR_DBPASS=000000

#Password for Keystore Kuryr user. exmaple:000000
KURYR_PASS=000000

#--------------------Ceilometer Config----------------##
#Password for Gnocchi ceilometer user. exmaple:000000
CEILOMETER_DBPASS=000000

#Password for Keystore ceilometer user. exmaple:000000
CEILOMETER_PASS=000000

#--------------------AODH Config----------------##
#Password for Mysql AODH user. exmaple:000000
AODH_DBPASS=000000

#Password for Keystore AODH user. exmaple:000000
AODH_PASS=000000

#--------------------Barbican Config----------------##
#Password for Mysql Barbican user. exmaple:000000
BARBICAN_DBPASS=000000

#Password for Keystore Barbican user. exmaple:000000
BARBICAN_PASS=000000

编辑完成后将文件从 controller 节点传进 compute 节点

[root@controller ~]# scp /etc/xiandian/openrc.sh compute:/etc/xiandian/openrc.sh
Are you sure you want to continue connecting (yes/no)? yes
root@compute's password: 000000

两个节点执行部署脚本

[root@controller ~]# iaas-pre-host.sh
[root@compute ~]# iaas-pre-host.sh

当两个节点都出现 Please Reboot or Reconnect the terminal 时,执行reboot命令

[root@controller ~]# reboot
[root@compute ~]# reboot

执行相关服务部署脚本

安装数据库服务

[root@controller ~]# iaas-install-mysql.sh

安装认证服务

[root@controller ~]# iaas-install-keystone.sh

安装镜像服务

[root@controller ~]# iaas-install-glance.sh

安装计算服务

[root@controller ~]# iaas-install-nova-controller.sh

Warning: 等待 controller 节点计算服务安装完成后,再执行 compute 节点的安装,之后的服务亦然如此

[root@compute ~]# iaas-install-nova-compute.sh

安装网络服务

[root@controller ~]# iaas-install-neutron-controller.sh
[root@compute ~]# iaas-install-neutron-compute.sh

安装Dashboard服务

[root@controller ~]# iaas-install-dashboard.sh

安装块存储服务

[root@controller ~]# iaas-install-cinder-controller.sh
[root@compute ~]# iaas-install-cinder-compute.sh

安装对象存储服务

[root@controller ~]# iaas-install-swift-controller.sh
[root@compute ~]# iaas-install-swift-compute.sh

安装编排服务

[root@controller ~]# iaas-install-heat.sh

安装zun服务

[root@controller ~]# iaas-install-zun-controller.sh
[root@compute ~]# iaas-install-zun-compute.sh

安装监控服务

[root@controller ~]# iaas-install-ceilometer-controller.sh
[root@compute ~]# iaas-install-ceilometer-compute.sh

安装报警服务

[root@controller ~]# iaas-install-aodh.sh

添加控制节点的计算服务资源

修改控制节点 openrc.sh 配置文件

[root@controller ~]# vi /etc/xiandian/openrc.sh
#--------------------system Config--------------------##
#Controller Server Manager IP. example:x.x.x.x
HOST_IP=172.16.10.10

#Controller HOST Password. example:000000
HOST_PASS=000000

#Controller Server hostname. example:controller
HOST_NAME=controller

#Compute Node Manager IP. example:x.x.x.x
HOST_IP_NODE=172.16.10.10

#Compute HOST Password. example:000000
HOST_PASS_NODE=000000

#Compute Node hostname. example:compute
HOST_NAME_NODE=controller

[root@controller ~]# iaas-install-nova-compute.sh