搭建OpenStack云平台(双节点)
前言
提示:这里是用VM创建两台双网卡 CentOS7.6的虚拟机进行搭建;(配置根据实际情况)
在部署openstack前环境的root目录的大小就是创建云主机时能用到的空间,所以给创建centos时多划分空间给root目录
Controller:8G内存、4vCPU、300G磁盘;
Compute: 8G内存、4vCPU、100G磁盘、200G扩展磁盘;
Compute节点需要用扩展磁盘分两个区sdb1和sdb2给swift和cinder当后端存储;
需要用到CentOS-7-x86_64-DVD-1804.iso和IaaS-OpenStack-x86-64_v1.0.iso镜像
一张网卡100网段(内网卡)手动配置IP;
一张网卡200网段(外网卡)启用即可(DHCP);
关闭防火墙;
提示:完成了前言所要求的就可以进行以下操作
一、配置基础环境
配置基础安装环境
1. 修改主机名并配置映射文件;
controller:
hostnamectl set-hostname controller
cat /etc/hosts
192.168.100.10 controller
192.168.100.20 compute
compute:
hostnamectl set-hostname compute
cat /etc/hosts
192.168.100.10 controller
192.168.100.20 compute
2. 在Controller安装Yum源并安装Vsftp
mv /etc/yum.repos.d/* /home
cat /etc/yum.repos.d/local.repo ##创建一个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
yum -y install vsftpd
cat /etc/vsftpd.conf ##在最后添加一行
anon_root=/opt ##根据实际情况
3. Compute通过FTP安装Yum源;
mv /etc/yum.repos.d/* /home
cat /etc/yum.repos.d/ftp.repo ##创建一个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/iaas-repo ##事先将镜像上传并挂载到文件
gpgcheck = 0
enabled = 1
yum repolist ##查看Yum列表
二、搭建OpenStack云平台
1.配置OpenStack的环境变量
先安装iaas-openstack服务:
yum -y install iaas-openstack
配置OpenStack配置文件
vi /etc/iaas-openstack/openrc.sh
在vim模式下进行操作
%s/# ##将文件内行首的第一个#删掉
%s/PASS=/PASS=000000 ##将文件中的PASS=替换成PASS=000000
cat /etc/iaas-openstack/openrc.sh
#--------------------system Config--------------------##
#Controller Server Manager IP. example:x.x.x.x
HOST_IP=192.168.100.10 ##Controller节点IP
#Controller HOST Password. example:000000
HOST_PASS=000000 ##Controller节点密码
#Controller Server hostname. example:controller
HOST_NAME=controller ##Controller节点主机名
#Compute Node Manager IP. example:x.x.x.x
HOST_IP_NODE=192.168.100.20 ##Compute节点IP
#Compute HOST Password. example:000000
HOST_PASS_NODE=000000 ##Compute节点密码
#Compute Node hostname. example:compute
HOST_NAME_NODE=compute ##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.20 ##(本机内网卡 IP)
#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 ##Compute节点IP
#--------------------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
2.一键安装服务
配置好环境变量后开始运行脚本一键安装服务(按顺序)
iaas-pre-host.sh ##初始化环境,两个节点先打
controller:
iaas-install-mysql.sh
iaas-install-keystone.sh
iaas-install-glance.sh
iaas-install-nova-controller.sh
iaas-install-neutron-controller.sh
iaas-install-dashboard.sh
iaas-install-cinder-controller.sh
iaas-install-swift-controller.sh
compute:
iaas-install-nova-compute.sh ##等controller节点的nova跑完再运行
iaas-install-neutron-compute.sh
iaas-install-cinder-compute.sh
iaas-install-swift-compute.sh
3.修改nova配置文件
如果安装服务时无报错则继续
修改nova配置文件(以防创建出来的云主机无系统)
在Compute节点修改
cat /etc/nova/nova.conf
[libvirt]
virt_type=qemu ##在[libvirt]下添加此行即可
身份认证命令(每次重启或者CRT重连后第一件事就是打这条身份认证命令)
source /etc/keystione/admin-openrc.sh
4.访问Web
打开浏览器输入http://192.168.100.10/dashboard
访问成功即可(demo,admin,000000)
注意:系统信息那里的所有项都必须是激活和启动
可以通过下面这条命令查看域名用户和密吗
到这里搭建OpenStack平台双节点就结束了,如果有帮助的话可以支持一下博主,右下角按钮投喂博主。