部署架构
一台控制节点和一台计算节点组成简单架构OpenStack平台,控制节点安装MySQL、Keystone、Glance、Nova、Neutron、Dashboard等服务,主要作为认证、镜像管理节点,以及提供Nova和Neutron服务的管理节点。提供Dashboard界面服务。计算节点主要安装nova-compute和Neutron服务,Nova服务提供云主机服务,Neutron提供网络服务。通过Shell脚本进行OpenStack平台部署,脚本分为控制节点脚本和计算节点脚本,对应节点执行部署脚本。
规划节点
安装OpenStack平台的2个节点规划
第一张网卡 IP | 主机名 | 节点 |
192.168.100.10 | controller | 控制节点 |
192.168.100.20 | compute | 计算节点 |
-----------------------------------------------------------------------------------------------------
第二张网卡 IP | 主机名 | 节点 |
192.168.200.10 | controller | 控制节点 |
192.168.200.20 | compute | 计算节点 |
准备2台VMware虚拟机,手动最小化安装2台CentOS 7.2系统,作为OpenStack节点,第一张网卡为NAT模式,第二张网卡为仅主机模式,以及配置CPU虚拟化,计算节点至少使用4 GB内存,硬盘不小于50GB。第一张网卡网段为192.168.100.0/24,第二张网卡网段为192.168.200.0/24。并对compute节点分两个区为sda3与sda4。(教材是第一张网卡为仅主机模式,第二张网卡为NAT模式)
计算节点图片 略
输入重启网卡命令,并检查IP地址
systemctl restart network ip a
1. 基础环境配置
(1)IP地址配置控制节点和计算节点,安装最小化CentOS7.2操作系统,配置每个节点IP地址。并使用secureCRT进行连接。controller节点修改部分:
改名
hostnamectl set-hostname controller bash
修改hosts文件,把控制节点和计算节点加进去
vi /etc/hosts
192.168.100.10 controller 192.168.100.20 computer
配置防火墙规则
清除所以chains链
iptables -F iptables -X iptables -Z iptables-save
systemctl stop firewalld systemctl disable firewalld
配置yum源
先挂载centos镜像,创建文件夹,把挂载的镜像复制到新建的文件夹。
在挂载IAAS镜像包,把挂载的镜像复制到opt目录下即可。
mount -o loop /dev/cdrom /mnt/ mkdir /opt/centos cp -rf /mnt/* /opt/centos umount /mnt/
mount -o loop /dev/cdrom /mnt cp -rf /mnt/* /opt/ umount /mnt/
将网络yum源先移走,然后在自己创建一个yum文件
mv /etc/yum.repos.d/* /opt/ vi /etc/yum.repos.d/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 repolist
搭建ftp服务器
yum install -y vsftpd
vi /etc/vsftpd/vsftpd.conf
anon_root=/opt #添加
开启ftp服务,并设置开机自启动
systemctl start vsftpd systemctl enable vsftpd
控制节点下安装iaas-xiandian
yum install -y iaas-xiandian
编辑文件/etc/xiandian/openrc.sh 环境变量
vi /etc/xiandian/openrc.sh
改为以下内容
##--------------------system Config--------------------## ##Controller Server Manager IP. example:x.x.x.x HOST_IP=192.168.100.10 ##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 Node hostname. example:compute HOST_NAME_NODE=compute ##--------------------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 ##External Network Interface. example:eth1 INTERFACE_NAME=eno33554960 ##First Vlan ID in VLAN RANGE for VLAN Network. exmaple:101 #minvlan= ##Last Vlan ID in VLAN RANGE for VLAN Network. example:200 #maxvlan= ##--------------------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 ##--------------------Trove Config--------------------## ##Password for Mysql Trove User. exmaple:000000 TROVE_DBPASS=000000 ##Password for Keystore Trove User. exmaple:000000 TROVE_PASS=000000 ##--------------------Swift Config---------------------## ##Password for Keystore swift user. exmaple:000000 SWIFT_PASS=000000 ##The NODE Object Disk for Swift. example:md126p4. OBJECT_DISK=sdc1 ##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 ##--------------------Ceilometer Config----------------## ##Password for Mysql 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
改完后运行sh脚本
iaas-pre-host.sh
脚本安装完后重启
reboot
脚本部署
这里必须要按照顺序来执行sh脚本,不然会白给
执行数据库及消息列表服务安装脚本
iaas-install-mysql.sh
执行keystone认证服务安装
iaas-install-keystone.sh
执行glance镜像服务安装
iaas-install-glance.sh
执行nova计算服务安装
iaas-install-nova-controller.sh
执行neutron网络服务安装
iaas-install-neutron-controller.sh
执行gre网络安装
iaas-install-neutron-controller-gre.sh
执行Dashboard服务安装
iaas-install-dashboard.sh
控制节点的安装到此结束了
计算节点的安装
先改名
hostnamectl set-hostname compute bash
配置两张网卡的IP地址
TYPE=Ethernet BOOTPROTO=static DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no NAME=eno16777728 UUID=d160852d-0605-4482-bd7e-e2194a4ba767 DEVICE=eno16777728 ONBOOT=yes IPADDR=192.168.100.20 NETMASK=255.255.255.0 NETGATE=192.168.100.254
TYPE=Ethernet BOOTPROTO=static DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no NAME=eno33554952 UUID=84c46888-4a3b-4ffb-b462-3a4d6af175a3 DEVICE=eno33554952 ONBOOT=yes IPADDR=192.168.200.20 NETMASK=255.255.255.0 NETGATE=192.168.200.254
配置yum源(用控制节点的ftp) 并验证
mv /etc/yum.repos.d/* /opt/ vi /etc/yum.repos.d/loacal.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
yum repolist
配置域名解析
vi /etc/hosts
192.168.100.10 controller 192.168.100.20 computer
关闭防火墙和SELINUX安全模式
iptables -F iptables -X iptables -Z iptables-save systemctl stop firewalld systemctl disable firewalld
划分空白磁盘,cinder存储和swift存储(计算节点)
查看计算机的磁盘名称
给sdb分区成cinder 盘
[root@compute ~]# parted /dev/sdb GNU Parted 3.1 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mklabel gpt (parted) print Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 107GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags (parted) mkpart cinder 0 100GB Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? Ignore (parted) print Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 107GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 17.4kB 100GB 100GB cinder (parted) quit Information: You may need to update /etc/fstab.
给sdc分区成swift 盘
[root@compute ~]# parted /dev/sdc GNU Parted 3.1 Using /dev/sdc Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mklabel gpt (parted) print Model: VMware, VMware Virtual S (scsi) Disk /dev/sdc: 107GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags (parted) mkpart swift 0 100GB Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? Ignore (parted) print Model: VMware, VMware Virtual S (scsi) Disk /dev/sdc: 107GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 17.4kB 100GB 100GB swift (parted) quit Information: You may need to update /etc/fstab.
分区完成后查看效果为
计算节点下安装iaas-xiandian
yum install -y iaas-xiandian
编辑文件/etc/xiandian/openrc.sh 环境变量(最好不要玩在VI编辑一下粘贴,会丢一些文件)
vi /etc/xiandian/openrc.sh
##--------------------system Config--------------------## ##Controller Server Manager IP. example:x.x.x.x HOST_IP=192.168.100.10 ##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 Node hostname. example:compute HOST_NAME_NODE=compute ##--------------------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 ##External Network Interface. example:eth1 INTERFACE_NAME=eno33554952 ##First Vlan ID in VLAN RANGE for VLAN Network. exmaple:101 #minvlan= ##Last Vlan ID in VLAN RANGE for VLAN Network. example:200 #maxvlan= ##--------------------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 ##--------------------Trove Config--------------------## ##Password for Mysql Trove User. exmaple:000000 TROVE_DBPASS=000000 ##Password for Keystore Trove User. exmaple:000000 TROVE_PASS=000000 ##--------------------Swift Config---------------------## ##Password for Keystore swift user. exmaple:000000 SWIFT_PASS=000000 ##The NODE Object Disk for Swift. example:md126p4. OBJECT_DISK=sdc1 ##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 ##--------------------Ceilometer Config----------------## ##Password for Mysql 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
改完后运行sh脚本
iaas-pre-host.sh
脚本安装完后重启
reboot
脚本部署
这里必须要按照顺序来执行sh脚本,不然会白给
执行nova计算服务脚本
iaas-install-nova-compute.sh
执行neutron网络安装脚本
iaas-install-neutron-compute.sh
执行gre网络安装脚本
iaas-install-neutron-compute-gre.sh
打开网页http://你的IP控制节点IP地址/dashboard/ 就可以验证
-------------------------------------------------END-------------------------------------------------