前言:之前对Openstack进行了理论上的介绍,本次对Openstack进行部署安装,这次使用的是OpenStack本地yum源
1.本地YUM源部署
2.Openstack-操作系统安装
3.openstack-各节点环境配置
4.openstack一键式环境部署
5.openstack登陆测试
[root@localhost ~]# hostnamectl set-hostname ct
[root@localhost ~]# su
[root@ct ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.124.100
NETMASK=255.255.255.0
[root@ct ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.9.110
NETMASK=255.255.255.0
GATEWAY=192.168.9.1
//这里暂时不配置网关,等部署OpenStack的时候在开启,否则无法访问公网
[root@ct yum.repos.d]# vi /etc/resolv.conf
nameserver 8.8.8.8
nameserver 114.114.114.114
[root@ct ~]# systemctl restart network //重启网卡
[root@ct ~]# ip addr
。。。省略部分内容
2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:ae:bd:a7 brd ff:ff:ff:ff:ff:ff
inet 192.168.124.100/24 brd 192.168.124.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::22a3:8657:d157:8957/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: eth1: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:ae:bd:b1 brd ff:ff:ff:ff:ff:ff
inet 192.168.9.110/24 brd 192.168.9.255 scope global noprefixroute eth1
[root@localhost ~]# hostnamectl set-hostname c1
[root@localhost ~]# su
[root@c1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.124.110
NETMASK=255.255.255.0
[root@c1 ~]# systemctl restart network //重启网卡
[root@c1 ~]# ip addr
。。。省略部分内容
2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:ae:bd:a7 brd ff:ff:ff:ff:ff:ff
inet 192.168.124.110/24 brd 192.168.124.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::22a3:8657:d157:8957/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@ct ~]# cd /opt
[root@ct opt]# ls
openstack_rocky.tar.gz
[root@ct opt]# tar zxvf openstack_rocky.tar.gz -C /opt
[root@ct opt]# cd /etc/yum.repos.d/
[root@ct yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[root@ct yum.repos.d]# mkdir bak
[root@ct yum.repos.d]# mv C* bak/
[root@ct yum.repos.d]# vi openstack-rocky.repo //重新编辑一个yum本地源文件
[openstack]
name=rocky
baseurl=file:///opt/openstack_rocky
enabled=1
gpgcheck=0
[root@ct yum.repos.d]# mount /dev/sr0 /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@ct yum.repos.d]# vi /etc/fstab
/dev/sr0 /mnt iso9660 defaults 0 0
[root@ct yum.repos.d]# yum clean all
[root@ct yum.repos.d]# yum makecache
//c1步骤相同
[root@ct ~]# systemctl stop firewalld
[root@ct ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@ct ~]# setenforce 0
[root@ct ~]# vi /etc/selinux/config
7 SELINUX=disabled
[root@ct ~]# systemctl stop NetworkManager
[root@ct ~]# systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
//c1配置相同
[root@ct ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.124.100 ct
192.168.124.110 c1
[root@ct ~]# scp /etc/hosts [email protected]:/etc
[email protected]'s password:
hosts 100% 218 70.1KB/s 00:00
[root@ct ~]# ntpdate ntp.aliyun.com
26 Feb 23:43:58 ntpdate[76398]: adjust time server 203.107.6.88 offset -0.000285 sec
[root@ct ~]# ntpdate ntp.aliyun.com >> /var/log/ntpdate.log
[root@ct ~]# crontab -e //设置周期性计划
*/30 * * * * /usr/sbin/ntpdate ntp.aliyun.com >> /var/log/ntpdate.log
[root@ct ~]# systemctl restart crond
[root@ct ~]# systemctl enable crond
[root@ct ~]# yum install ntp -y
[root@ct ~]# vi /etc/ntp.conf
8 restrict default nomodify
17 restrict 192.168.124.0 mask 255.255.255.0 nomodify notrap
21 server 0.centos.pool.ntp.org iburst //21-24删除
22 server 1.centos.pool.ntp.org iburst
23 server 2.centos.pool.ntp.org iburst
24 server 3.centos.pool.ntp.org iburst
//删除的插入下面内容
21 fudeg 127.127.1.0 stratum 10
22 server 127.127.1.0
[root@ct ~]# systemctl disable chronyd.service //关闭系统时钟服务
Removed symlink /etc/systemd/system/multi-user.target.wants/chronyd.service.
[root@ct ~]# systemctl restart ntpd
[root@ct ~]# systemctl enable ntpd
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.
[root@c1 ~]# ntpdate ct
26 Feb 23:58:58 ntpdate[44196]: adjust time server 192.168.124.100 offset 0.010589 sec
[root@c1 ~]# crontab -e
*/30 * * * * /usr/sbin/ntpdate ct >> /var/log/ntpdate.log
[root@c1 ~]# systemctl restart crond
[root@c1 ~]# systemctl enable crond
[root@c1 ~]# systemctl disable chronyd.service
Removed symlink /etc/systemd/system/multi-user.target.wants/chronyd.service.
[root@c2 ~]# systemctl enable ntpdate
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpdate.service to /usr/lib/systemd/system/ntpdate.service.
[root@ct ~]# ssh-keygen -t rsa //一路回车即可
[root@ct ~]# ssh-copy-id ct //交互提示 输入yes 然后输入密码
[root@ct ~]# ssh-copy-id comp1
[root@ct ~]# ssh-copy-id comp2
[root@ct ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@ct ~]# yum -y install openstack-packstack //安装一键部署工具
[root@ct ~]# packstack --gen-answer-file=openstack.txt //生成应答文件
[root@ct ~]# vi openstack.txt
41 CONFIG_SWIFT_INSTALL=n //第41行SWIFT是OpenStack的对象存储组件,默认是Y,在生产环境中一般是不装,所以改n
50 CONFIG_AODH_INSTALL=n //第50行,默认是Y 需要改n
97 CONFIG_COMPUTE_HOSTS=192.168.124.110 //第97行需要更改计算节点的IP地址
101 CONFIG_NETWORK_HOSTS=192.168.124.100 //第101行 需要更改网络节点的IP地址
782 CONFIG_LBAAS_INSTALL=y //第782行 LBAAS负载均衡组件。必选要装 选y
790 CONFIG_NEUTRON_FWAAS=y //第790行 FWAAS是防火墙组件。必选要装 选y
794 CONFIG_NEUTRON_VPNAAS=y //第794行 VPNAAS是VPN组件。必选要装 选y
817 CONFIG_NEUTRON_ML2_FLAT_NETWORKS=physnet1 //第817行,FLAT网络这边要设置物理网卡名字
862 CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=physnet1:br-ex //第862行,这边要设置物理网卡的名字
873 CONFIG_NEUTRON_OVS_BRIDGE_IFACES=br-ex:eth1 //第873行,这边br-ex:eth1是网络节点的nat网卡
1185 CONFIG_PROVISION_DEMO=n //第1185行 是OpenStack联网下载一个测试镜像,这边没联网。说以改成n
[root@ct ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
。。。省略部分内容
GATEWAY=192.168.124.1
[root@ct ~]# systemctl restart network //重启网卡
[root@ct ~]# sed -i -r 's/(.+_PW)=.+/\1=1234/' openstack.txt //将密码修改为1234
[root@ct ~]# sed -i -r 's/192.168.9.110/192.168.124.100/g' openstack.txt //将节点变成192.168.124.100
[root@ct ~]# grep -vE "^#|^$" openstack.txt >openstackbak.txt //备份文件
[root@ct ~]# packstack --answer-file=openstack.txt //开始部署
[root@ct ~]# ls
anaconda-ks.cfg keystonerc_admin openstackbak.txt openstack.txt
[root@ct ~]# cat keystonerc_admin
unset OS_SERVICE_TOKEN
export OS_USERNAME=admin //用户名
export OS_PASSWORD='1234' //密码
export OS_AUTH_URL=http://192.168.124.100:5000/v3
export PS1='[\u@\h \W(keystone_admin)]\$ '
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_IDENTITY_API_VERSION=3