文章目录
- OpenStack的搭建方式
- 实验软件及镜像
- 实验环境
- 配置NTP节点
- 初始化配置
- 配置本地yum仓库
- 上传镜像文件至NTP节点
- 搭建基于http的网络yum源
- 搭建NTP服务
- 配置Controller控制节点和Compute计算节点
- 初始化配置
- 安装RedHat OpenStack
- 安装部署OpenStack
- 配置OVS桥接
OpenStack的搭建方式
- Allinone
- 在一台服务节点上安装阉割版的OpenStack,再使用此节点,在其他三个节点上安装不同的组件
- TrpileO(OpenStack On OpenStack)
- PackStack(RedHat)
- Ansbile(自动化运维工具)
- 原生OpenStack安装时,是手动安装各个组件
实验软件及镜像
- 镜像【下载】,提取码Bad5
软件 作用 VMware Workstation Pro 用于部署实验主机节点 Xshell/Putty/Mobaxterm 用于远程连接节点主机 WinSCP 用于上传ISO镜像文件至节点主机 rhel-server-7.1-x86_64-dvd.iso 用于安装节点主机的镜像文件 RHEL7OSP-6.0-2015-02-23.2-x86_64.iso 用于安装搭建OpenStack small.img 用于发放云主机
实验环境
- 实验使用的为RHEL7.1版本的Linux,网络模式为仅主机模式,桥接到物理主机的VMnet1网卡,VMnnet1网卡的IP作为节点主机的DNS服务器
主机名 IP地址 功能 配置 NTP 192.168.43.128 提供 NTP服务以及网络YUM源 2CPU/1G_RAM/200G_Disk Controller 192.168.43.129 作为管理节点和计算节点 2CPU/4G_RAM/200G_Disk Compute 192.168.43.130 作为计算节点 2CPU/4G_RAM/200G_Disk 物理主机VMnet1 192.168.43.1
配置NTP节点
初始化配置
- 修改主机名为NTP
- 关闭SeLinux
- 配置主机的IP地址、子网掩码、网关以及DNS
- 禁止NetworkManager开机自启
- 关闭防火墙并禁止防火墙开机自启,检查防火墙的状态
- 重启节点主机
[root@localhost ~]# vim /etc/hostname
NTP
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
TYPE=Ethernet
BOOTPROTO=static
NAME=eno16777736
DEVICE=eno16777736
ONBOOT=yes
IPADDR=192.168.43.128
NETMASK=255.255.255.0
GATEWAY=192.168.43.1
DNS1=192.168.43.1
[root@localhost ~]# systemctl disable NetworkManager
[root@localhost ~]# systemctl stop firewall.service
[root@localhost ~]# systemctl disable firewall.service
[root@localhost ~]# systemctl status firewall.service
firewall.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
[root@localhost ~]# reboot
配置本地yum仓库
- 配置本地yum源文件
- 挂载RHEL7.1的镜像文件到NTP节点主机的/mnt下
[root@NTP ~]# cd /etc/yum.repos.d/
[root@NTP yum.repos.d]# ls
[root@NTP yum.repos.d]# vim RHEL.repo
[Base]
name=RHEL
baseurl=file:///mnt
gpgcheck=0
enable=1
[root@NTP yum.repos.d]# mount /dev/cdrom /mnt/ #将ISO文件挂载到/mnt下
mount: /dev/sr0 is write-protected, mounting read-only
[root@NTP yum.repos.d]# yum clean all #清除yum缓存
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: InstallMedia Base
Cleaning up everything
[root@NTP yum.repos.d]# yum repolist #刷新yum仓库
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Base | 4.1 kB 00:00
(1/2): Base/group_gz | 134 kB 00:00
(2/2): Base/primary_db | 3.4 MB 00:00
repo id repo name status
Base RHEL 4,371
repolist: 4,371
上传镜像文件至NTP节点
- 创建/iso目录,用于存放镜像文件
- 使用WinSCP或Mobaxterm将镜像文件上传到NTP节点
[root@NTP ~]# mkdir /iso
[root@NTP ~]# cd /iso/
[root@NTP iso]# ls
RHEL7OSP-6.0-2015-02-23.2-x86_64.iso rhel-server-7.1-x86_64-dvd.iso
搭建基于http的网络yum源
- 安装http服务,启动http服务,并设置开机自启动
- 查看http服务的状态
- 创建发布目录,并配置镜像文件开机自动挂载到发布目录
- 重新配置基于http的网络yum源仓库,并测试网络yum源的可用性(如果在yum仓库的目录中还有系统自动生成的其他.repo的文件,需要全部删掉,避免影响之后的实验)
[root@NTP ~]# yum -y install httpd
[root@NTP ~]# systemctl start httpd
[root@NTP ~]# systemctl enable httpd
[root@NTP ~]# systemctl status httpd
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: active (running) since Thu 2023-01-12 15:55:35 CST; 19s ago
Main PID: 10713 (httpd)
......
[root@NTP ~]# mkdir /var/www/html/{ISO,OpenStack}
[root@NTP ~]# cd /var/www/html/
[root@NTP html]# ls
ISO OpenStack
[root@NTP html]# vim /etc/fstab #配置开机自动挂载
[root@NTP html]# tail -2 /etc/fstab
/iso/rhel-server-7.1-x86_64-dvd.iso /var/www/html/ISO iso9660 defaults,loop,ro 0 0
/iso/RHEL7OSP-6.0-2015-02-23.2-x86_64.iso /var/www/html/OpenStack iso9660 defaults,loop,ro 0 0
[root@NTP html]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 50G 7.1G 43G 15% /
devtmpfs 481M 0 481M 0% /dev
tmpfs 490M 140K 490M 1% /dev/shm
tmpfs 490M 7.1M 483M 2% /run
tmpfs 490M 0 490M 0% /sys/fs/cgroup
/dev/sda1 497M 124M 373M 25% /boot
/dev/mapper/rhel-home 148G 33M 148G 1% /home
/dev/sr0 3.7G 3.7G 0 100% /mnt
[root@NTP html]# mount -a #重新读取fstab文件,进行挂载
[root@NTP html]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 50G 7.1G 43G 15% /
devtmpfs 481M 0 481M 0% /dev
tmpfs 490M 140K 490M 1% /dev/shm
tmpfs 490M 7.1M 483M 2% /run
tmpfs 490M 0 490M 0% /sys/fs/cgroup
/dev/sda1 497M 124M 373M 25% /boot
/dev/mapper/rhel-home 148G 33M 148G 1% /home
/dev/sr0 3.7G 3.7G 0 100% /mnt
/dev/loop0 3.7G 3.7G 0 100% /var/www/html/ISO
/dev/loop1 515M 515M 0 100% /var/www/html/OpenStack
[root@NTP html]# cd /etc/yum.repos.d/
[root@NTP yum.repos.d]# vim RHEL.repo
[Base]
name=RHEL
baseurl=http://192.168.43.128/ISO
gpgcheck=0
enable=1
[root@NTP yum.repos.d]# vim OpenStack.repo
[RH7-RHOS-6.0-Installer]
name=RH7-RHOS-6.0-Installer
baseurl=http://192.168.43.128/OpenStack/RH7-RHOS-6.0-Installer
gpgcheck=0
enabled=1
[RH7-RHOS-6.0]
name=RH7-RHOS-6.0
baseurl=http://192.168.43.128/OpenStack/RH7-RHOS-6.0
gpgcheck=0
enabled=1
[RHEL-7-RHSCL-1.2]
name=RHEL-7-RHSCL-1.2
baseurl=http://192.168.43.128/OpenStack/RHEL-7-RHSCL-1.2
gpgcheck=0
enabled=1
[RHEL7-Errata]
name=RHEL7-Errata
baseurl=http://192.168.43.128/OpenStack/RHEL7-Errata
gpgcheck=0
enabeld=1
[root@NTP yum.repos.d]# yum clean all
[root@NTP yum.repos.d]# yum repolist all
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Base | 4.1 kB 00:00
RH7-RHOS-6.0 | 1.3 kB 00:00
RH7-RHOS-6.0-Installer | 1.2 kB 00:00
RHEL-7-RHSCL-1.2 | 3.3 kB 00:00
RHEL7-Errata | 2.9 kB 00:00
(1/6): Base/group_gz | 134 kB 00:00
(2/6): Base/primary_db | 3.4 MB 00:00
(3/6): RH7-RHOS-6.0/primary | 117 kB 00:00
(4/6): RHEL-7-RHSCL-1.2/primary_db | 776 kB 00:00
(5/6): RHEL7-Errata/primary_db | 10 kB 00:00
(6/6): RH7-RHOS-6.0-Installer/primary | 47 kB 00:00
RH7-RHOS-6.0 393/393
RH7-RHOS-6.0-Installer 194/194
repo id repo name status
Base RHEL enabled: 4,371
RH7-RHOS-6.0 RH7-RHOS-6.0 enabled: 393
RH7-RHOS-6.0-Installer RH7-RHOS-6.0-Installer enabled: 194
RHEL-7-RHSCL-1.2 RHEL-7-RHSCL-1.2 enabled: 1,766
RHEL7-Errata RHEL7-Errata enabled: 11
repolist: 6,735
搭建NTP服务
- 安装NTP服务
- 配置NTP服务,将NTP节点主机作为服务端。控制节点和计算节点会向NTP节点进行时间同步
- 启动NTP服务,并设置开机自启动,查看NTP服务的状态
- 关闭chrony服务,并禁止开机自启。此服务也可以作为时间同步服务器,会和NTP冲突
[root@NTP yum.repos.d]# cd
[root@NTP ~]# rpm -qa | grep ntp #查看是否安装了NTP服务
ntpdate-4.2.6p5-19.el7_0.x86_64
fontpackages-filesystem-1.44-8.el7.noarch
[root@NTP ~]# yum -y install ntp
....
Installed:
ntp.x86_64 0:4.2.6p5-19.el7_0
Complete!
[root@NTP ~]# vim /etc/ntp.conf #将网络时间同步服务器注释,配置自身作为时间同步服务器
......
21 #server 0.rhel.pool.ntp.org iburst
22 #server 1.rhel.pool.ntp.org iburst
23 #server 2.rhel.pool.ntp.org iburst
24 #server 3.rhel.pool.ntp.org iburst
25
26 server 127.127.1.0 #配置时间同步服务器为自身
27 fudge 127.127.1.0 stratum 10 #配置自身作为时间同步服务器
......
[root@NTP ~]# systemctl start ntpd
[root@NTP ~]# systemctl enable ntpd #配置NTP服务开机自启动
ln -s '/usr/lib/systemd/system/ntpd.service' '/etc/systemd/system/multi-user.target.wants/ntpd.service'
[root@NTP ~]# systemctl status ntpd
ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled)
Active: active (running) since Thu 2023-01-12 16:24:12 CST; 18s ago
Main PID: 21546 (ntpd)
CGroup: /system.slice/ntpd.service
└─21546 /usr/sbin/ntpd -u ntp:ntp -g
......
[root@NTP ~]# systemctl stop chrony
[root@NTP ~]# systemctl disable chronyd.service
rm '/etc/systemd/system/multi-user.target.wants/chronyd.service'
[root@NTP ~]# systemctl status chronyd.service
chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; disabled)
Active: inactive (dead)
......
NTP节点配置完成
配置Controller控制节点和Compute计算节点
初始化配置
- 修改主机名为Controller
- 关闭SeLinux
- 配置主机的IP地址、子网掩码、网关以及DNS(这里回归了网卡传统命名,所以是ifcfg-eth0)
- 禁止NetworkManager开机自启
- 关闭防火墙并禁止防火墙开机自启,检查防火墙的状态
- 重启节点主机
[root@localhost ~]# vim /etc/hostname
Controller
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.43.129
NETMASK=255.255.255.0
GATEWAY=192.168.43.1
DNS1=192.168.43.1
[root@localhost ~]# systemctl disable NetworkManager
[root@localhost ~]# systemctl stop firewall.service
[root@localhost ~]# systemctl disable firewall.service
[root@localhost ~]# systemctl status firewall.service
firewall.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
[root@localhost ~]# reboot
重启完成后,测试与NTP节点主机的连通性
- 在NTP节点主机,将配置好的网络yum源仓库文件传给Controller控制节点
[root@NTP ~]# cd /etc/yum.repos.d/
[root@NTP yum.repos.d]# ls
OpenStack.repo redhat.repo RHEL.repo
[root@NTP yum.repos.d]# rm -rf redhat.repo
[root@NTP yum.repos.d]# ls
OpenStack.repo RHEL.repo
[root@NTP yum.repos.d]# scp ./* root@192.168.43.129:/etc/yum.repos.d/
The authenticity of host '192.168.43.129 (192.168.43.129)' can't be established.
ECDSA key fingerprint is e9:ee:b8:50:13:9b:f7:de:70:ef:44:1f:11:35:cb:54.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.43.129' (ECDSA) to the list of known hosts.
root@192.168.43.129's password:
OpenStack.repo 100% 473 0.5KB/s 00:00
RHEL.repo 100% 71 0.1KB/s 00:00
- 在控制节点测试网络yum源仓库的可用性
[root@Controller ~]# cd /etc/yum.repos.d/
[root@Controller yum.repos.d]# ls
OpenStack.repo redhat.repo RHEL.repo
[root@Controller yum.repos.d]# yum clean all
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: Base RH7-RHOS-6.0 RH7-RHOS-6.0-Installer RHEL-7-RHSCL-1.2
: RHEL7-Errata
Cleaning up everything
[root@Controller yum.repos.d]# yum repolist all
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Base | 4.1 kB 00:00
RH7-RHOS-6.0 | 1.3 kB 00:00
RH7-RHOS-6.0-Installer | 1.2 kB 00:00
RHEL-7-RHSCL-1.2 | 3.3 kB 00:00
RHEL7-Errata | 2.9 kB 00:00
(1/6): Base/group_gz | 134 kB 00:00
(2/6): RHEL7-Errata/primary_db | 10 kB 00:00
(3/6): RH7-RHOS-6.0-Installer/primary | 47 kB 00:00
(4/6): RH7-RHOS-6.0/primary | 117 kB 00:00
(5/6): Base/primary_db | 3.4 MB 00:00
(6/6): RHEL-7-RHSCL-1.2/primary_db | 776 kB 00:00
RH7-RHOS-6.0 393/393
RH7-RHOS-6.0-Installer 194/194
repo id repo name status
Base RHEL enabled: 4,371
RH7-RHOS-6.0 RH7-RHOS-6.0 enabled: 393
RH7-RHOS-6.0-Installer RH7-RHOS-6.0-Installer enabled: 194
RHEL-7-RHSCL-1.2 RHEL-7-RHSCL-1.2 enabled: 1,766
RHEL7-Errata RHEL7-Errata enabled: 11
repolist: 6,735
- 在Compute计算节点同样的初始化配置节点主机,并测试连通性
- 将NTP节点主机的yum源仓库文件上传到Compute计算节点上,并测试网络yum源仓库的可用性
安装RedHat OpenStack
- 在控制节点安装packstack工具,用于安装部署OpenStack
- 安装完成后,检查控制节点的DNS是否配置正确。如果配置不正确,需要在网卡的配置文件中重新配置DNS
[root@Controller ~]# yum -y install openstack-packstack
......
Installed:
openstack-packstack.noarch 0:2014.2-0.16.dev1401.gdd19d48.el7ost
Dependency Installed:
PyYAML.x86_64 0:3.10-11.el7
libyaml.x86_64 0:0.1.4-11.el7_0
openstack-packstack-puppet.noarch 0:2014.2-0.16.dev1401.gdd19d48.el7ost
openstack-puppet-modules.noarch 0:2014.2.8-2.el7ost
......
Complete!
[root@Controller ~]# cat /etc/resolv.conf
nameserver 192.168.43.1
安装部署OpenStack
- 生成应答文件,并修改该应答文件
- 利用应答文件,使用packstack工具安装OpenStack
[root@Controller ~]# packstack --gen-answer-file=/root/ans.txt
Packstack changed given value to required value /root/.ssh/id_rsa.pub
[root@Controller ~]# cd /root/
[root@Controller ~]# ls
anaconda-ks.cfg Desktop Downloads Music Public Videos
ans.txt Documents initial-setup-ks.cfg Pictures Templates
[root@Controller ~]# vim ans.txt
......
67 CONFIG_NTP_SERVERS=192.168.43.128 #配置NTP服务器节点
......
85 CONFIG_CONTROLLER_HOST=192.168.43.129 #配置控制节点
......
89 CONFIG_COMPUTE_HOSTS=192.168.43.129,192.168.43.130 #配置多计算节点,控制节点复用
......
93 CONFIG_NETWORK_HOSTS=192.168.43.129 #配置网络节点,控制节点暂代
......
246 CONFIG_KEYSTONE_ADMIN_PW=badboy #配置Web界面管理员登录密码
......
560 CONFIG_HORIZON_SSL=y #配置加密通信的Web界面
......
629 CONFIG_PROVISION_DEMO=n #配置不创建演示环境
......
[root@Controller ~]# packstack --answer-file=/root/ans.txt
Welcome to the Packstack setup utility
The installation log file is available at: /var/tmp/packstack/20230112-173134-eqBcat/openstack-setup.log
Installing:
Clean Up [ DONE ]
root@192.168.43.129's password:
root@192.168.43.130's password:
Setting up ssh keys [ DONE ]
Discovering hosts' details [ DONE ]
......
Applying 192.168.43.130_postscript.pp
192.168.43.130_postscript.pp: [ DONE ]
192.168.43.129_postscript.pp: [ DONE ]
Applying Puppet manifests [ DONE ]
Finalizing [ DONE ]
**** Installation completed successfully ******
Additional information:
......
登录OpenStack首页测试:https://192.168.43.129/dashboard,登录成功后无需做配置
配置OVS桥接
- 修改控制节点的网卡配置文件
- 先将网卡配置文件做备份 , 防止出现故障时无法恢复
- 创建OVS桥接,修改网卡配置文件
- 修改网卡桥接,重启网络服务
[root@Controller ~]# cd /etc/sysconfig/network-scripts/
[root@Controller network-scripts]# cp ifcfg-eth0 ifcfg-eth0.bak
[root@Controller network-scripts]# cp ifcfg-eth0 ifcfg-br-ex
[root@Controller network-scripts]# vim ifcfg-br-ex
TYPE=OVSBridge
NAME=br-ex
DEVICE=br-ex
ONBOOT=yes
DEVICETYPE=ovs
OVS_BRIDGE=br-ex
IPADDR=192.168.43.129
NETMASK=255.255.255.0
GATEWAY=192.168.43.1
DNS1=192.168.43.1
[root@Controller network-scripts]# vim ifcfg-eth0
TYPE=OVSPort
NAME=eth0
DEVICE=eth0
ONBOOT=yes
DEVICETYPE=ovs
OVS_BRIDGE=br-ex
[root@Controller network-scripts]# service network restart
Restarting network (via systemctl): [ OK ]
[root@Controller network-scripts]# ifconfig
br-ex: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.43.129 netmask 255.255.255.0 broadcast 192.168.43.255
inet6 fe80::742d:32ff:fe73:e74f prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:52:94:1d txqueuelen 0 (Ethernet)
RX packets 93 bytes 7953 (7.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 137 bytes 17053 (16.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
br-int: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::14b6:b1ff:fe67:294e prefixlen 64 scopeid 0x20<link>
ether 16:b6:b1:67:29:4e txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8 bytes 648 (648.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::20c:29ff:fe52:941d prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:52:94:1d txqueuelen 1000 (Ethernet)
RX packets 212126 bytes 219696484 (209.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 106409 bytes 18842452 (17.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 496279 bytes 74615394 (71.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 496279 bytes 74615394 (71.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
以上内容均属原创,如有不详或错误,敬请指出。
本文链接: http://t.csdn.cn/Rotab
版权声明: 本博客所有文章转载请联系作者注明出处并附带本文链接!