Packstack一键部署openstack-R版
2020-06-12 本文已影响0人
Linux丶晨星
三台节点
#controller节点
nat:192.168.0.110 仅主机:10.0.1.110
#ccomputel01节点
nat:192.168.0.120 仅主机:10.0.1.120
#ccomputel02节点
nat:192.168.0.130 仅主机:10.0.1.130
网卡配置
其他节点配置相同,只有IP不同
#nat
[root@controller ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.0.110
PREFIX=24
GATEWAY=192.168.0.254
DNS1=223.5.5.5
#仅主机
[root@controller ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
BOOTPROTO=static
DEVICE=eth1
ONBOOT=yes
IPADDR=10.0.1.110
PREFIX=24
GATEWAY=10.0.1.1
DNS=223.5.5.5
控制节点
ssh分发秘钥
[root@controller ~]# yum install -y bind-utils sshpass
[root@controller ~]# mkdir -p /server/scripts
[root@controller ~]# cat >/server/scripts/fenfa_pub.sh<< EOF
#!/bin/bash
ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ''
for ip in 110 120 130
do
sshpass -p123456 ssh-copy-id -o StrictHostKeyChecking=no 10.0.1.\$ip
done
EOF
sh /server/scripts/fenfa_pub.sh
hosts解析
[root@controller ~]# cat >>/etc/hosts <<EOF
192.168.0.110 controller
192.168.0.120 computel01
192.168.0.130 computel02
EOF
for ip in 120 130 ;do scp -rp /etc/hosts root@192.168.0.$ip:/etc/hosts ;done
[root@controller ~]# ping computel01
PING computel01 (10.0.1.120) 56(84) bytes of data.
64 bytes from computel01 (192.168.0.120): icmp_seq=1 ttl=64 time=0.432 ms
[root@controller ~]# ping computel02
PING computel02 (10.0.1.130) 56(84) bytes of data.
64 bytes from computel02 (10.0.1.130): icmp_seq=1 ttl=64 time=0.389 ms
全部节点的基础优化
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
systemctl stop NetworkManager
systemctl disable NetworkManager
上传软件包——openstack-rocky压缩包
链接: https://pan.baidu.com/s/1raa5Wj8LEDQ0DwSe7vDPeQ 提取码: e4pd
全部节点,解压到/opt目录下
如下所示:
[root@controller ~]# ls
openstack_rocky.tar.gz
[root@controller ~]# tar -zxf openstack_rocky.tar.gz -C /opt/
[root@controller ~]# cd /opt/
[root@controller opt]# du -h
2.4M ./openstack_rocky/repodata
306M ./openstack_rocky
306M .
将光盘镜像挂载
[root@controller opt]# echo '/dev/sr0 /mnt iso9660 defaults 0 0' >>/etc/fstab
[root@controller opt]# mount /dev/sr0 /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@controller opt]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 99G 2.4G 97G 3% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 12M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 297M 110M 188M 37% /boot
tmpfs 797M 0 797M 0% /run/user/0
/dev/sr0 4.3G 4.3G 0 100% /mnt
yum源
[root@controller opt]# cd /etc/yum.repos.d/
[root@controller yum.repos.d]#
[root@controller yum.repos.d]# mkdir backup #创建备份目录
[root@controller yum.repos.d]# mv ./C* ./epel.repo backup/ #将当前目录下,所有内容转移到./backup
[root@controller yum.repos.d]# cp backup/CentOS-Base.repo local.repo
[root@controller yum.repos.d]# vim local.repo
[openstack]
name=openstack
baseurl=file:///opt/openstack_rocky
gpgcheck=0
enabled=1
[centos]
name=centos
baseurl=file:///mnt
gpgcheck=0
enabled=1
#开启缓存
[root@controller yum.repos.d]# sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf
[root@controller yum.repos.d]# yum clean all ##检验本地源是否正常
[root@controller yum.repos.d]# yum makecache ##检查本地源是否工作正常
[root@controller ~]# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id repo name status
centos centos enabled: 4,021
openstack openstack enabled: 787
repolist: 4,808
时间同步
#controller节点
yum install chrony -y
vim /etc/chrony.conf
server ntp1.aliyun.com iburst
allow 192.168.0.10/24
systemctl restart chronyd.service
systemctl enable chronyd.service
chronyc sources
#其他节点上配置
yum install chrony -y
vim /etc/chrony.conf
server controller iburst
systemctl restart chronyd.service
systemctl enable chronyd.service
chronyc sources
一键部署OpenStack
控制节点安装openstack-packstack工具
#安装openstack-packstack工具用于生成openstack应答文件(txt文本格式)
[root@controller ~]# yum install -y openstack-packstack
[root@controller ~]# packstack --gen-answer-file=openstack.txt
[root@controller ~]# ls
openstack_rocky.tar.gz openstack.txt
修改一键部署配置文件的内容
具体内容建议查询了解其他的配置含义和作用
[root@controller ~]# vim openstack.txt
41行:y-n #SWIFT是OpenStack的对象存储组件,默认是Y,在生产环境中一般是不装,所以改n
50行:y-n #不安装该服务
97行:10.0.1.120,10.0.1.130 #计算节点ip地址
817 :physnet1 #flat网络这边要设置物理网卡名字
862 :physnet1:br-ex #这边要设置物理网卡的名字
873:br-ex:eth0 #这边br-ex:eth0是网络节点的nat网卡,到时候安装完毕之后IP地址会漂到这个上
1185:y-n #DEMO是OpenStack联网下载一个测试镜像,这边没联网。说以改成n
还有一些网段需要修改以及密码这里使用sed正则表达式来全局修改
##更改密码(123456)
[root@controller ~]# sed -i -r 's/(.+_PW)=.+/\1=123456/' openstack.txt
##将主机ip修改为仅主机网络
sed -i -r 's/192.168.0.110/10.0.1.110/g' openstack.txt
#进行备份
egrep -v "^#|^$" openstack.txt >openstack.txt.bak1
[root@controller ~]# grep 'HOST=' openstack.txt
CONFIG_CONTROLLER_HOST=10.0.1.110
CONFIG_VCENTER_HOST=
CONFIG_STORAGE_HOST=10.0.1.110
CONFIG_SAHARA_HOST=10.0.1.110
CONFIG_AMQP_HOST=10.0.1.110
CONFIG_MARIADB_HOST=10.0.1.110
CONFIG_TEMPEST_HOST=
CONFIG_REDIS_HOST=10.0.1.110
使用下面的命令进行一键部署安装
#保证控制节点的仅主机网络网关打开
#在各个节点终端(可以多开几个窗口终端使用下面的命令查看日志信息)
[root@controller ~]# tail -f /var/log/messages
[root@computel01 ~]# tail -f /var/log/messages
[root@computel02 ~]# tail -f /var/log/messages
接下来就是耐心等待
[root@controller ~]# packstack --answer-file=openstack.txt
Welcome to the Packstack setup utility
The installation log file is available at: /var/tmp/packstack/20200612-145549-x939Z7/openstack-setup.log
Installing:
Clean Up [ DONE ]
Discovering ip protocol version [ DONE ]
Setting up ssh keys [ DONE ]
Preparing servers [ DONE ]
Pre installing Puppet and discovering hosts' details [ DONE ]
Preparing pre-install entries [ DONE ]
Setting up CACERT [ DONE ]
Preparing AMQP entries [ DONE ]
Preparing MariaDB entries [ DONE ]
Fixing Keystone LDAP config parameters to be undef if empty[ DONE ]
Preparing Keystone entries [ DONE ]
Preparing Glance entries [ DONE ]
Checking if the Cinder server has a cinder-volumes vg[ DONE ]
Preparing Cinder entries [ DONE ]
Preparing Nova API entries [ DONE ]
Creating ssh keys for Nova migration [ DONE ]
Gathering ssh host keys for Nova migration [ DONE ]
Preparing Nova Compute entries [ DONE ]
Preparing Nova Scheduler entries [ DONE ]
Preparing Nova VNC Proxy entries [ DONE ]
Preparing OpenStack Network-related Nova entries [ DONE ]
Preparing Nova Common entries [ DONE ]
Preparing Neutron LBaaS Agent entries [ DONE ]
Preparing Neutron API entries [ DONE ]
Preparing Neutron L3 entries [ DONE ]
Preparing Neutron L2 Agent entries [ DONE ]
Preparing Neutron DHCP Agent entries [ DONE ]
Preparing Neutron Metering Agent entries [ DONE ]
Checking if NetworkManager is enabled and running [ DONE ]
Preparing OpenStack Client entries [ DONE ]
Preparing Horizon entries [ DONE ]
Preparing Gnocchi entries [ DONE ]
Preparing Redis entries [ DONE ]
Preparing Ceilometer entries [ DONE ]
Preparing Puppet manifests [ DONE ]
Copying Puppet modules and manifests [ DONE ]
Applying 10.0.1.110_controller.pp
10.0.1.110_controller.pp: [ DONE ]
Applying 10.0.1.110_network.pp
10.0.1.110_network.pp: [ DONE ]
Applying 10.0.1.120_compute.pp
Applying 10.0.1.130_compute.pp
10.0.1.130_compute.pp: [ DONE ]
10.0.1.120_compute.pp: [ DONE ]
Applying Puppet manifests [ DONE ]
Finalizing [ DONE ]
**** Installation completed successfully ******
Additional information:
* Time synchronization installation was skipped. Please note that unsynchronized time on server instances might be problem for some OpenStack components.
* File /root/keystonerc_admin has been created on OpenStack client host 10.0.1.110. To use the command line tools you need to source the file.
* To access the OpenStack Dashboard browse to http://10.0.1.110/dashboard .
Please, find your login credentials stored in the keystonerc_admin in your home directory.
* The installation log file is available at: /var/tmp/packstack/20200612-145549-x939Z7/openstack-setup.log
* The generated manifests are available at: /var/tmp/packstack/20200612-145549-x939Z7/manifests
[END] 2020/6/12 15:21:05
出现
**** Installation completed successfully ******
则就表示安装成功了
登陆访问操作(账户密码可从账户环境变量配置查看)
http://10.0.1.110/dashboard
账户 admin
密码 123456
openstack安装完以后,启动顺序、关机顺序
关机:计算–网络–控制
开机:控制–网络–计算
检查节点启动情况
[root@controller ~]# source keystonerc_admin
[root@controller ~(keystone_admin)]# openstack network agent list
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+
| ID | Agent Type | Host | Availability Zone | Alive | State | Binary |
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+
| 1d494d1d-7cc3-437d-9885-d1bca9dfafe2 | Open vSwitch agent | computel02 | None | :-) | UP | neutron-openvswitch-agent |
| 68a6c589-c95e-45f4-99eb-ed59ec816f46 | DHCP agent | controller | nova | :-) | UP | neutron-dhcp-agent |
| 7412a954-78fd-4a9f-9205-1ace139d036b | Metadata agent | controller | None | :-) | UP | neutron-metadata-agent |
| 97167cf1-3180-47a4-a884-4141f5c89959 | L3 agent | controller | nova | :-) | UP | neutron-l3-agent |
| b45a5a85-9ab5-445f-a3e0-ca36bfbc7dad | Open vSwitch agent | computel01 | None | :-) | UP | neutron-openvswitch-agent |
| b976f2b9-4286-40ea-bbc9-cf0e1e819fc6 | Open vSwitch agent | controller | None | :-) | UP | neutron-openvswitch-agent |
| d0bdf0f5-db3f-45d0-b3a7-21628bfa906a | Metering agent | controller | None | :-) | UP | neutron-metering-agent |
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+