OpenStack云平台搭建需要两个节点,一个是controller(控制节点),另一个是compute(计算节点)。
控制节点(controller) |
一块200G硬盘 |
第一张网卡使用:192.168.100.10 第二张网卡使用:192.168.200.10 |
计算节点(compute) |
一块200G硬盘+一块100G硬盘 |
第一张网卡使用:192.168.100.20 第二张网卡使用:192.168.200.20 |
云平台搭建需要使用centos7.5及7.0版本的镜像和chinaskills_cloud_iaas.iso镜像
镜像提供如下:部署所需的两个镜像
基础环境准备及安装系统
controller基础搭建配置:
具体输入完成图为:输入完成之后回车即可:
进行修改主机名:
hostnamectl set-hostname controller
bash
修改第一张网卡信息:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
配置为:
进行重启网卡查看ip是否生效,用本机测试是否与外网相互通信:
systemctl restart network
修改第二块网卡:
vi /etc/sysconfig/network-scripts/ifcfg-eth1
重启网卡查看ip:
systemctl restart network
修改内核:
vi /etc/default/grub/
原文件内容:
修改为:
保存退出,刷新内核,然后重启使配置生效:
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
compute基础搭建配置:
进行修改主机名:
hostnamectl set-hostname compute
bash
配置第一张网卡:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
配置第二张网卡:
vi /etc/sysconfig/network-scripts/ifcfg-eth1
重启网卡查看ip,主机测试通信情况:
systemctl restart network
ip add
正式搭建openstack云平台
controller节点配置
首先我们使用CRT进行连接192.168.100.10的ip进行上传镜像至节点controller中:
关闭防火墙和selinux:
[root@controller ~]# systemctl stop firewalld #关闭防火墙
[root@controller ~]# systemctl disable firewalld #设置防火墙开机不自启
[root@controller ~]# setenforce 0 #临时关闭selinux防火墙,0表示关闭,1表示开启
[root@controller ~]# getenforce #查看selinux防火墙的状态
Permissive
[root@controller ~]# vi /etc/selinux/config #非临时性
进入之后修改SELINUX为
查看刚才上传的镜像:
进行挂载镜像:
[root@controller ~]# mount -o loop CentOS-7-x86_64-DVD-1804.iso /mnt/
[root@controller ~]# mkdir /opt/centos
[root@controller ~]# cp -rf /mnt/* /opt/centos/
[root@controller ~]# umount /mnt/
[root@controller ~]# mount -o loop chinaskills_cloud_iaas.iso /mnt/
[root@controller ~]# cp -rf /mnt/* /opt/
[root@controller ~]# umount /mnt/
yum源文件处理
移除yum源:
[root@controller ~]# cd /etc/yum.repos.d/
[root@controller yum.repos.d]# mv * /media/
[root@controller yum.repos.d]# ls
写入yum源文件:
[root@controller yum.repos.d]# vi local.repo
写入如下内容:
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=file:///opt/iaas-repo
gpgcheck=0
enabled=1
进行查看:
清除yum源缓存,验证yum源,下载所需软件包:
[root@controller yum.repos.d]# yum clean all #清除yum源缓存
[root@controller yum.repos.d]# yum repolist #列出所有可用的yum源
[root@controller yum.repos.d]# yum install -y vim vsftpd iaas-xiandian #安装所需的软件包
配置vsftpd:
[root@controller yum.repos.d]# echo anon_root=/opt/ >> /etc/vsftpd/vsftpd.conf #设置匿名访问
[root@controller yum.repos.d]# systemctl restart vsftpd #重启ftp服务
[root@controller yum.repos.d]# systemctl enable vsftpd #设置ftp服务开机自启
修改脚本:
[root@controller ~]# vim /etc/xiandian/openrc.sh
原文件内容:
需要删除所有第一行注释:
在非注释模式下按下:CTrl+v然后按下shift+g然后再按下D即可删除注释
如下图:
取消注释之后对其进行修改:
图片看不清可以按照如下进行配置:
#--------------------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 Server hostname. example:controller
HOST_NAME=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 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 #controller节点所在的网段
#--------------------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 #本机IP地址
#External Network Interface. example:eth1
INTERFACE_NAME=eth1
#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 #compute节点的存储块
#--------------------Swift Config---------------------##
#Password for Keystore swift user. exmaple:000000
SWIFT_PASS=000000
#The NODE Object Disk for Swift. example:md126p4.
OBJECT_DISK=sdb2 #compute节点的存储块
#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
comoute节点配置
关闭防火墙,selinux:
[root@compute ~]# systemctl stop firewalld
[root@compute ~]# systemctl disable firewalld
[root@compute ~]# setenforce 0
[root@compute ~]# getenforce
[root@compute ~]# vi /etc/selinux/config
硬盘分区:
[root@compute ~]# fdisk /dev/sdb
yum源文件处理
移除yum源:
[root@compute ~]# cd /etc/yum.repos.d/
[root@compute yum.repos.d]# mv * /media/
[root@compute yum.repos.d]# ls
写入yum源文件:
[root@compute yum.repos.d]# vi local.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
保存查看:
[root@compute yum.repos.d]# cat local.repo
清除yum源缓存,验证yum源,下载所需软件包:
[root@compute yum.repos.d]# yum clean all
[root@compute yum.repos.d]# yum repolist
[root@compute yum.repos.d]# yum install -y vim iaas-xiandian
修改脚本
将controller节点的脚本复制到compute节点:
[root@compute ~]# scp 192.168.100.10:/etc/xiandian/openrc.sh /etc/xiandian/openrc.sh
需要修改compute节点脚本:
[root@compute ~]# vim /etc/xiandian/openrc.sh
第70行修改成本机ip:
刷脚本
controller节点需要刷下列脚本:
[root@controller ~]# iaas-pre-host.sh #刷完该脚本后需要重启
[root@controller ~]# iaas-install-mysql.sh
[root@controller ~]# iaas-install-keystone.sh
[root@controller ~]# source /etc/keystone/admin-openrc.sh #使环境生效
[root@controller ~]# iaas-install-glance.sh
[root@controller ~]# iaas-install-nova-controller.sh
[root@controller ~]# iaas-install-neutron-controller.sh
[root@controller ~]# iaas-install-dashboard.sh
compute节点需要刷下列脚本:
[root@compute ~]# iaas-pre-host.sh #刷完该脚本后需要重启
[root@compute ~]# iaas-install-nova-compute.sh
[root@compute ~]# iaas-install-neutron-compute.sh
登录OpenStack云平台
输入:
http://192.168.100.10/dashboard
输入账号密码:
进行连接: