一一道云openstack平台部署

发布时间 2023-10-17 19:56:09作者: cyj爱study

一,初始化环境部署

先将chinaskills_cloud_iaas.iso镜像文件上传到controller节点的/root下

controller节点和compute节点都配置两块网卡,仅主机和NAT模式各一块

controller节点

1. 配置网络,修改ip地址

2. 修改主机名

hostnamectl set-hostname controller

3. 关闭防火墙和selinux

systemctl stop firewalld && systemctl disable firewalld

setenforce 0

sed -i 'g/SELINUX=enforcing/SELINUX=disabled/s' /etc/selinux/conf

systemctl status firewalld

getenforce

4. 挂载镜像,设置本地yum源

mkdir /opt/{centos,iaas}

mount /dev/sr0 /opt/centos

mount /root/chinaskills_cloud_iaas.iso /opt/iaas -o loop

echo 'mount /dev/sr0 /opt/centos

mount /root/chinaskills_cloud_iaas.iso /opt/iaas -o loop' >> /etc/rc.local

mv /etc/yum.repos.d/* /meida

cat /etc/yum.repos.d/loacl.repo

[centos]

name=centos

baseurl=file:///opt/centos

enabled=1

gpgcheck=0

[iaas]

name=iaas

baseurl=file:///opt/iaas/iaas-repo

enabled=1

gpgcheck=0

yum clean all

yum repolist

5. 下载安装ftp并设置匿名访问目录

yum install vsftpd -y

echo 'anon_root=/opt' >> /etc/vsftpd/vsftpd.conf

systemctl start vsftpd && systemctl enable vsftpd

6. 设置ip地址与主机映射

echo '192.168.108.10 comtroller

192.168.108.11 compute' >> /etc/hosts

compute节点

1. 配置网络,修改ip地址

2. 修改主机名

hostnamectl set-hostname compute

3. 关闭防火墙和selinux

systemctl stop firewalld && systemctl disable firewalld

setenforce 0

sed -i 'g/SELINUX=enforcing/SELINUX=disabled/s' /etc/selinux/conf

systemctl status firewalld

getenforce

4. 配置本地yum源

mv /etc/yum.repos.d/* /media

cat /etc/yum.repos.d/local.repo

[centos]

name=centos

baseurl=ftp://controller/centos

enabled=1

gpgcheck=0

[iaas]

name=iaas

baseurl=ftp://controller/iaas/iaas-repo

enabled=1

gpgcheck=0

yum clean all

yum repolist

5. 设置主机与ip 地址映射

echo '192.168.108.10 controller

192.168.108.11 compute' >> /etc/hosts

 

二,下载并编辑openstack搭建使用的脚本变量文件

controller节点

yum install openstack-iaas -y

vi /etc/openstack/openrc.sh

:1,$s/#//

:1,$s/#/##/

:1,$s/PASS=/PASS=/PASS=000000/

##--------------------system Config--------------------##

##Controller Server Manager IP. example:x.x.x.x

HOST_IP=controller节点的ip

 

##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=compute节点ip地址

 

##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=使用的网段

 

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

 

##--------------------Placement Config----------------------##

##Password for Mysql placement user. exmaple:000000

PLACEMENT_DBPASS=000000

 

##Password for Keystore placement user. exmaple:000000

PLACEMENT_PASS=000000

 

##--------------------Nova Config----------------------##

##Password for Mysql nova user. exmaple:000000

NOVA_DBPASS=000000

 

##Password for Keystore nova user. exmaple:000000

NOVA_PASS=000000

 

##--------------------Neutron 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

 

##External Network Interface. example:eth1

INTERFACE_NAME=NAT模式下的网卡

 

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

 

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

 

##--------------------Swift Config---------------------##

##Password for Keystore swift user. exmaple:000000

SWIFT_PASS=000000

 

##The NODE Object Disk for Swift. example:md126p4.

OBJECT_DISK=

 

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

STORAGE_LOCAL_NET_IP=

 

##--------------------Trove Config----------------------##

##Password for Mysql trove user. exmaple:000000

TROVE_DBPASS=000000

 

##Password for Keystore trove user. exmaple:000000

TROVE_PASS=000000

 

##--------------------Heat Config----------------------##

##Password for Mysql heat user. exmaple:000000

HEAT_DBPASS=000000

 

##Password for Keystore heat user. exmaple:000000

HEAT_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

 

##--------------------ZUN Config----------------##

##Password for Mysql ZUN user. exmaple:000000

ZUN_DBPASS=000000

 

##Password for Keystore ZUN user. exmaple:000000

ZUN_PASS=000000

 

##Password for Keystore KURYR user. exmaple:000000

KURYR_PASS=000000

 

##--------------------OCTAVIA Config----------------##

##Password for Mysql OCTAVIA user. exmaple:000000

OCTAVIA_DBPASS=000000

 

##Password for Keystore OCTAVIA user. exmaple:000000

OCTAVIA_PASS=000000

 

##--------------------Manila Config----------------##

##Password for Mysql Manila user. exmaple:000000

MANILA_DBPASS=000000

 

##Password for Keystore Manila user. exmaple:000000

MANILA_PASS=000000

 

##The NODE Object Disk for Manila. example:md126p5.

SHARE_DISK=

 

##--------------------Cloudkitty Config----------------##

##Password for Mysql Cloudkitty user. exmaple:000000

CLOUDKITTY_DBPASS=000000

 

##Password for Keystore Cloudkitty user. exmaple:000000

CLOUDKITTY_PASS=000000

 

##--------------------Barbican Config----------------##

##Password for Mysql Barbican user. exmaple:000000

BARBICAN_DBPASS=000000

 

##Password for Keystore Barbican user. exmaple:000000

BARBICAN_PASS=000000

compute节点

yum install openstack-iaas -y

通过scp将已经编辑好的openrc.sh文件直接复制到compute节点以减少工作量

scp /etc/openstack/oprc.sh root@compute节点的ip地址:/etc/openstack/oprenrc.sh

三,运行脚本搭建openstack平台

运行脚本时同一组件尽量先执行controller节点再执行compute节点,避免报错

controller节点

iaas-pre-host

iaas-install.mysql.sh

iaas-install-keystone.sh

iaas-install-glance.sh

iaas-install-placement.sh

iaas-install-nova-controller.sh

iaas-install-neutron-controller.sh

iaas-install-dashboard.sh

compute节点

iaas-pre-host.sh

iaas-install-nova-compute.sh

iaas-install-neutron-compute.sh

iaas-install-dashboard.sh