配置ip地址、配置主机名

controller节点:
网卡1:192.168.100.10
网卡2:192.168.200.10
compute节点:
网卡1:192.168.100.20
网卡2:192.168.200.20

网卡1为仅主机模式,网卡2为NAT模式,两台虚拟机密码设置为000000

建议两台节点运行内存给到6G(6144MB)

cotroller ifcfg-ens33

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=ens33
UUID=4a667240-2f76-4ddc-b0b1-65bbe67ca7d5
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.100.10
PREFIX=24

cotroller ifcfg-ens34

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=ens34
UUID=3de5461f-2339-4cda-8b46-4df997c74bd5
DEVICE=ens34
ONBOOT=yes
IPADDR=192.168.200.10
PREFIX=24
GATEWAY=192.168.200.2

compute ifcfg-ens33

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=ens33
UUID=ef0eaa9c-1330-4616-85d7-9a91ac44a596
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.100.20
PREFIX=24

compute ifcfg-ens34

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=ens34
UUID=fb2363f3-8c7b-4bca-a6e5-5e23827cc644
DEVICE=ens34
ONBOOT=yes
IPADDR=192.168.200.20
PREFIX=24
GATEWAY=192.168.200.2

配置主机名

[root@controller ~]hostnamectl set-hostname controller
[root@compute ~]hostnamectl set-hostname compute

修改hosts文件将IP地址映射为主机名

[root@controller ~]vi /etc/hosts
192.168.100.10 controller
192.168.100.20 compute
[root@compute ~]vi /etc/hosts
192.168.100.10 controller
192.168.100.20 compute

磁盘分区

compute节点,添加一块200g硬盘

[root@compute-pjl ~]# parted /dev/sdb
GNU Parted 3.1
使用 /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
新的磁盘标签类型? gpt
(parted) mkpart cinder 1G 101G
(parted) mkpart swift 101G 201G
(parted) q
信息: You may need to update /etc/fstab.

[root@compute-pjl ~]# mkfs.xfs /dev/sdb1
[root@compute-pjl ~]# mkfs.xfs /dev/sdb2

配置本地yum源

【controller】

[root@controller ~]cd /etc/yum.repos.d/
[root@controller ~]mkdir bak
[root@controller ~]mv *.repo bak
[root@controller ~]vi /etc/yum.repos.d/centos.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=file:///opt/iaas-repo
gpgcheck=0
enabled=1

【compute】

[root@compute ~]cd /etc/yum.repos.d/
[root@compute ~]mkdir bak
[root@compute ~]mv *.repo bak
[root@compute ~]vi /etc/yum.repos.d/centos.repo
[centos]
name=centos
baseurl=ftp://192.168.100.10/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=ftp://192.168.100.10/iaas-repo
gpgcheck=0
enabled=1

挂载镜像

【controller】

在虚拟机右下角设置CD/DVD
选择CentOS-7-x86_64-DVD-1804.iso镜像,并连接

[root@controller ~]# mount -o loop /dev/cdrom /mnt/
[root@controller ~]# mkdir /opt/centos
[root@controller ~]# cp -rvf /mnt/* /opt/centos/
[root@controller ~]# umount /mnt/

在虚拟机右下角设置CD/DVD
选择chinaskills_cloud_iaas.iso镜像,并连接

[root@controller ~]# mount -o loop /dev/cdrom /mnt/
[root@controller ~]# cp -rvf /mnt/* /opt/
[root@controller ~]# umount /mnt/

搭建ftp服务器,开启并设置自启

[root@controller ~]# yum install vsftpd –y
[root@controller ~]# vi /etc/vsftpd/vsftpd.conf
末尾添加 anon_root=/opt/
wq!保存退出
[root@controller ~]# systemctl start vsftpd
[root@controller ~]# systemctl enable vsftpd

关闭防火墙配置selinux

【controller/compute】

systemctl stop firewalld
systemctl disable firewalld
# vi /etc/selinux/config
SELINUX=disabled

清除缓存,验证 yum 源

【controller/compute】

# yum clean all
# yum list
# yum repolist
//显示repolist: 7,203即为成功。

编辑环境变量

【controller/compute】

# yum install iaas-xiandian -y

【controller】

vi /etc/xiandian/openrc.sh
##--------------------system Config--------------------##
##Controller Server Manager IP. example:x.x.x.x
HOST_IP=192.168.100.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=192.168.100.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=192.168.100.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=192.168.100.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=101

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

##--------------------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=sdb1

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

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

##The NODE IP for Swift Storage Network. example:x.x.x.x.
STORAGE_LOCAL_NET_IP=192.168.100.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】

scp /etc/xiandian/openrc.sh root@192.168.100.20:/etc/xiandian

【compute】

vi /etc/xiandian/openrc.sh

修改一个地方即可

INTERFACE_IP=192.168.100.20

安装openstack包

【controller/compute】

执行脚本命令iaas-pre-host.sh进行安装
# 安装完成后同时重启或者logout
[root@controller ~]# reboot
两台主机source /etc/xiandian/openrc.sh

安装Mysql数据库服务

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

安装Keystone认证服务

[root@controller ~]#iaas-install-keystone.sh
[root@controller ~]# source /etc/keystone/admin-openrc.sh
[root@controller ~]# systemctl status neutron-linuxbridge-agent

安装Glance镜像服务

[root@controller ~] iaas-install-glance.sh
[root@controller ~] systemctl status openstack-glance-registry

上传镜像

[root@controller ~] source /etc/keystone/admin-openrc.sh
[root@controller ~] cd /opt/images/
[root@controller ~] source admin-openrc.sh
[root@controller ~] glance image-create --name "CentOS7.5" --disk-format qcow2 --container-format bare --progress < /opt/images/CentOS_7.5_x86_64_XD.qcow2

安装Nova计算服务

[root@controller ~] iaas-install-nova-controller.sh
[root@controller ~]# systemctl status openstack-nova-novncproxy
[root@compute ~]iaas-install-nova-compute.sh
[root@compute-pjl ~]systemctl status openstack-nova-compute

安装Neutron网络服务

[root@controller ~]iaas-install-neutron-controller.sh
[root@controller ~]systemctl status neutron-server

[root@compute ~]iaas-install-neutron-compute.sh
[root@compute-pjl ~]systemctl status neutron-linuxbridge-agent

安装Dashboard服务

[root@controller ~] iaas-install-dashboard.sh
[root@controller ~]# source /etc/keystone/admin-openrc.sh

安装Cinder块存储服务

[root@controller ~] iaas-install-cinder-controller.sh
[root@controller ~] systemctl status openstack-cinder-scheduler

[root@compute ~]iaas-install-cinder-compute.sh
[root@compute-pjl ~] systemctl status openstack-cinder-volume

安装Swift对象存储服务

[root@controller ~] iaas-install-swift-controller.sh
[root@controller ~]# systemctl status openstack-swift-proxy

[root@compute ~] iaas-install-swift-compute.sh
[root@compute-pjl ~] lsblk #查看sdb2是否挂载到/swift/node/sdb2

安装Heat编配服务

[root@controller ~]iaas-install-heat.sh
[root@controller ~]# systemctl status openstack-heat-engine

安装Zun服务

[root@controller ~] iaas-install-zun-controller.sh
[root@controller ~]# systemctl status zun-wsproxy

[root@compute ~] iaas-install-zun-compute.sh
[root@compute-pjl ~]# systemctl status zun-compute

以CentOS7_1804.tar镜像为例
CentOS7_1804.tar镜像包存放在XianDian-IaaS-v2.4.iso镜像包中。将docker镜像上传到glance中,通过openstack使用镜像启动容器。

[root@controller ~] source /etc/keystone/admin-openrc.sh

[root@controller ~] cd /opt/images/

[root@controller ~] openstack image create centos7.5 --public --container-format docker --disk-format raw < CentOS7_1804.tar
[root@controller ~] openstack image list

安装Ceilometer监控服务

[root@controller ~]iaas-install-ceilometer-controller.sh进行安装
[root@controller ~]# systemctl status openstack-ceilometer-central

[root@compute ~] iaas-install-ceilometer-compute.sh进行安装
[root@compute-pjl~]# systemctl status openstack-ceilometer-compute

安装Aodh监控服务

[root@controller ~]iaas-install-aodh.sh
[root@controller ~]# systemctl status openstack-aodh-listener

添加控制节点资源到云平台

【controller】

[root@controller ~] vi /etc/xiandian/openrc.sh 

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

#Compute HOST Password. example:000000
HOST_PASS_NODE=000000

#Compute Node hostname. example:compute
HOST_NAME_NODE=controller

[root@controller ~]# source /etc/xiandian/openrc.sh
[root@controller ~] iaas-install-nova-compute.sh

登陆云平台dashboard

在浏览器中输入http://192.168.100.10/dashboard
注:检查防火墙规则,确保允许 http 服务相关端口通行,或者关闭防火墙。
创建云主机(gre/vlan)
(1)管理员 → 网络 → 创建网络(内外网) → 创建子网(外网填服务器的外网网段)
(2)项目 → 网络 → 路由 → 新建路由 → 添加网关和内网接口
(3)项目 → 计算 → 访问安全 → 管理规则 → 添加规则(ICMP、TCP、UDP)
(4)项目 → 计算 → 云主机 → 创建云主机 → 绑定浮动 IP