
文章目录CentOS-Stream-8-packstack安装OpenStack前期准备1、资源清单2、虚拟机硬件配置3、网络拓扑步骤一准备模板虚拟机配置yum源安装方便操作环境包及基础软件包设置/etc/hosts关闭SELinux编辑网卡信息清除密钥信息清除Machine ID关闭操作系统并拍快照。步骤二准备openstack节点克隆虚拟机并修改基础配置配置主机名配置IP地址配置NTP测试测试关闭操作系统拍摄快照步骤三安装OpenStack和测试控制节点安装packstack生成应答文件更改应答文件关闭NetworkManager根据应答文件配置安装openstack安装完成登录测试开启network服务配置OpenStack命令补全关机拍快照CentOS-Stream-8-packstack安装OpenStack前期准备1、资源清单CentOS-Stream-8(minimal安装) -CentOS-Stream-8-20240603.0-x86_64-dvd1.isohttps://mirrors.aliyun.com/centos-vault/8-stream/isos/x86_64/CentOS-Stream-8-20240603.0-x86_64-dvd1.iso?spma2c6h.25603864.0.0.33e24ee4AiZUTJvmware workstation17.5OpenStack-Victoria2、虚拟机硬件配置controller 4CPU 8G内存 1张网卡:NAT 100G系统盘compute 4CPU 8G内存 1张网卡:NAT 100G系统盘按照个人情况配置内存3、网络拓扑vmware网络设置NAT网络,开启DHCP192.168.108.0/24网关192.168.108.2DNS 192.168.108.2说明Windows环境vmware的NAT网络网关为192.168.108.2Linux环境vmware的NAT网络网关为192.168.108.1/etc/hosts192.168.108.10 controller192.168.108.11 compute步骤一准备模板虚拟机基于CentOS-Stream-8模板制作.pdf 制作的模板克隆出一个虚拟机(openstack_template)作为openstack模板虚拟机完整克隆克隆好后开机配置配置yum源# 清除默认yum源配置[rootlocalhost ~]# rm -rf /etc/yum.repos.d/*# 创建OpenStack yum源配置文件[rootlocalhost ~]# cat EOF /etc/yum.repos.d/openstack.repo[centos-openstack-victoria]nameCentOS8- OpenStack victoriabaseurlhttps://mirrors.aliyun.com/centos-vault/8-stream/cloud/x86_64/openstack-victoria/gpgcheck0enabled1[highavailability]nameCentOS Stream8- HighAvailabilitybaseurlhttps://mirrors.aliyun.com/centos-vault/8-stream/HighAvailability/x86_64/os/gpgcheck0enabled1[nfv]nameCentOS Stream8- NFVbaseurlhttps://mirrors.aliyun.com/centos-vault/8-stream/NFV/x86_64/os/gpgcheck0enabled1[rt]nameCentOS Stream8- RTbaseurlhttps://mirrors.aliyun.com/centos-vault/8-stream/RT/x86_64/os/gpgcheck0enabled1[resilientstorage]nameCentOS Stream8- ResilientStoragebaseurlhttps://mirrors.aliyun.com/centos-vault/8-stream/ResilientStorage/x86_64/os/gpgcheck0enabled1[extras-common]nameCentOS Stream8- Extras packagesbaseurlhttps://mirrors.aliyun.com/centos-vault/8-stream/extras/x86_64/extras-common/gpgcheck0enabled1[extras]nameCentOS Stream$releasever- Extrasbaseurlhttps://mirrors.aliyun.com/centos-vault/8-stream/extras/x86_64/os/gpgcheck0enabled1[centos-ceph-pacific]nameCentOS - Ceph Pacificbaseurlhttps://mirrors.aliyun.com/centos-vault/8-stream/storage/x86_64/ceph-pacific/gpgcheck0enabled1[centos-rabbitmq-38]nameCentOS-8 - RabbitMQ38baseurlhttps://mirrors.aliyun.com/centos-vault/8-stream/messaging/x86_64/rabbitmq-38/gpgcheck0enabled1[centos-nfv-openvswitch]nameCentOS Stream8- NFV OpenvSwitchbaseurlhttps://mirrors.aliyun.com/centos-vault/8-stream/nfv/x86_64/openvswitch-2/gpgcheck0enabled1[baseos]nameCentOS Stream8- BaseOSbaseurlhttps://mirrors.aliyun.com/centos-vault/8-stream/BaseOS/x86_64/os/gpgcheck0enabled1[appstream]nameCentOS Stream8- AppStreambaseurlhttps://mirrors.aliyun.com/centos-vault/8-stream/AppStream/x86_64/os/gpgcheck0enabled1[powertools]nameCentOS Stream8- PowerToolsbaseurlhttps://mirrors.aliyun.com/centos-vault/8-stream/PowerTools/x86_64/os/gpgcheck0enabled1EOF# 清除yum缓存[rootlocalhost ~]# yum clean all0files removed# 生成yum缓存[rootlocalhost ~]# yum makecache安装方便操作环境包及基础软件包# 安装软件包[rootlocalhost ~]# yum install -y bash-completion vim open-vm-tools net-tools chrony.x86_64# 加载bash自动补全[rootlocalhost ~]# source /usr/share/bash-completion/bash_completion设置/etc/hosts# 配置主机名与IP映射[rootlocalhost ~]# echo 192.168.108.10 controller /etc/hosts# 配置主机名与IP映射[rootlocalhost ~]# echo 192.168.108.11 compute /etc/hosts关闭SELinux# 关闭SELinux[rootlocalhost ~]# sed -i /^SELINUX/cSELINUXdisabled /etc/selinux/config编辑网卡信息# 切换到网卡配置目录[rootlocalhost ~]# cd /etc/sysconfig/network-scripts/# 编辑网卡配置文件[rootlocalhost network-scripts]# vim ifcfg-ens160TYPEEthernetBOOTPROTOdhcpNAMEens160DEVICEens160ONBOOTyes清除密钥信息# 切换到SSH配置目录[rootlocalhost ~]# cd /etc/ssh/# 删除SSH主机密钥[rootlocalhost ssh]# rm -rf ssh_host_*清除Machine ID# 清空Machine ID[rootlocalhost ~]# cat /dev/null /etc/machine-id# 查看Machine ID[rootlocalhost ~]# cat /etc/machine-id关闭操作系统并拍快照。# 关闭虚拟机[rootlocalhost ~]# poweroff步骤二准备openstack节点克隆虚拟机并修改基础配置采用完全克隆方法克隆出其他2台虚拟机openstack_controller , openstack_compute。同样的操作克隆计算节点2节点的CPU需要开启虚拟化支持。两节点配置不同的IP主机名两节点分别开机做以下配置配置主机名controller:# 设置主机名[rootlocalhost ~]# hostnamectl set-hostname controllercompute:# 设置主机名[rootlocalhost ~]# hostnamectl set-hostname compute配置IP地址controller:# 编辑网卡配置文件[rootcontroller ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens160TYPEEthernetBOOTPROTOnone #这行从dhcp 变更为 noneNAMEens160DEVICEens160ONBOOTyesIPADDR192.168.108.10NETMASK255.255.255.0GATEWAY192.168.108.2DNS1192.168.108.2# 重新加载网卡配置[rootcontroller ~]# nmcli connection reload ens160# 启用网卡[rootcontroller ~]# nmcli connection up ens160compute:# 编辑网卡配置文件[rootcompute ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens160TYPEEthernetBOOTPROTOnone #这行从dhcp 变更为 noneNAMEens160DEVICEens160ONBOOTyesIPADDR192.168.108.11NETMASK255.255.255.0GATEWAY192.168.108.2DNS1192.168.108.2# 重新加载网卡配置[rootcontroller ~]# nmcli connection reload ens160# 启用网卡[rootcontroller ~]# nmcli connection up ens160配置NTPcontroller:# 编辑时间同步配置文件[rootcontroller ~]# vim /etc/chrony.conf3# pool 2.centos.pool.ntp.org iburst4server ntp.aliyun.com iburst22# Allow NTP client access from local network.23#allow 192.168.0.0/1624allow192.168.108.0/24#启动服务# 重启时间同步服务[rootcontroller ~]# systemctl restart chronyd# 设置时间同步服务开机自启[rootcontroller ~]# systemctl enable chronyd测试# 查看时间同步源[rootcontroller ~]# chronyc sources -v.-- Source mode^server,peer,#localclock. / .- Source state*current best,combined,-not combined,|/xmay beinerror,~too variable,?unusable.||.- xxxx[yyyy]/- zzzz||Reachability register(octal)-.|xxxxadjusted offset,||Log2(Polling interval)--.||yyyymeasured offset,||\||zzzzestimated error.||||\MS Name/IP address Stratum Poll Reach LastRx Last sample^*203.107.6.88261745-479us[-1323us]/- 27mscompute:# 编辑时间同步配置文件[rootcompute ~]# vim /etc/chrony.conf# pool 2.centos.pool.ntp.org iburstserver controller iburst#启动服务# 重启时间同步服务[rootcompute ~]# systemctl restart chronyd# 设置时间同步服务开机自启[rootcompute ~]# systemctl enable chronyd测试# 查看时间同步源[rootcompute ~]# chronyc sources -v.-- Source mode^server,peer,#localclock. / .- Source state*current best,combined,-not combined,|/xmay beinerror,~too variable,?unusable.||.- xxxx[yyyy]/- zzzz||Reachability register(octal)-.|xxxxadjusted offset,||Log2(Polling interval)--.||yyyymeasured offset,||\||zzzzestimated error.||||\MS Name/IP address Stratum Poll Reach LastRx Last sample^? controller070- 0ns[0ns]/- 0ns关闭操作系统拍摄快照controller:# 关闭虚拟机[rootcontroller ~]# poweroffcompute:# 关闭虚拟机[rootcompute ~]# poweroff步骤三安装OpenStack和测试控制节点安装packstackcontroller:# 安装软件包[rootcontroller ~]# yum install -y openstack-packstack生成应答文件controller:# 生成PackStack应答文件[rootcontroller ~]# packstack --gen-answer-fileanswers.txtPackstack changed given value to required value /root/.ssh/id_rsa.pub Additional information: * Parameter CONFIG_NEUTRON_L2_AGENT: You have chosen OVN Neutron backend. Note that this backend does not support the VPNaaS plugin. Geneve will be used as the encapsulation methodfortenant networks更改应答文件controller:# 编辑PackStack应答文件[rootcontroller ~]# vim answers.txt60CONFIG_HEAT_INSTALLy97CONFIG_COMPUTE_HOSTS192.168.108.10,192.168.108.11909CONFIG_NEUTRON_OVN_BRIDGE_IFACESbr-ex:ens1601169CONFIG_PROVISION_DEMOn# 批量修改应答文件中的密码[rootcontroller ~]# sed -i.bak -r s/(._PW)[0-9a-z]/\1huawei/g answers.txt关闭NetworkManagercontroller:# 停止并禁用NetworkManager服务[rootcontroller ~]# systemctl stop NetworkManager; systemctl disable NetworkManager; systemctl mask NetworkManagercompute:# 停止并禁用NetworkManager服务[rootcompute ~]# systemctl stop NetworkManager; systemctl disable NetworkManager; systemctl mask NetworkManagerCentOS 8 版本默认使用 NetworkManager 管理网络但它会和 openstack 网络组件产生冲突从而导致告警或错误根据应答文件配置安装openstackcontroller:# 执行PackStack安装OpenStack[rootcontroller ~]# packstack --answer-fileanswers.txtWelcome to the Packstack setup utility The installation logfileis available at: /var/tmp/packstack/20240920-102825-fai6j5rg/openstack-setup.log Installing: Clean Up[DONE]Discoveringipprotocol version[DONE]root192.168.108.10s password:huawei root192.168.108.11s password:huawei Setting upsshkeys[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 undefifempty[DONE]Preparing Keystone entries[DONE]Preparing Glance entries[DONE]Checkingifthe Cinder server has a cinder-volumes vg[DONE]Preparing Cinder entries[DONE]Preparing Nova API entries[DONE]CreatingsshkeysforNova migration[DONE]GatheringsshhostkeysforNova 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 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]CheckingifNetworkManager is enabled and running[DONE]Preparing OpenStack Client entries[DONE]Preparing Horizon entries[DONE]Preparing Swift builder entries[DONE]Preparing Swift proxy entries[DONE]Preparing Swift storage entries[DONE]Preparing Heat entries[DONE]Preparing Heat CloudFormation API entries[DONE]Preparing Gnocchi entries[DONE]Preparing Redis entries[DONE]Preparing Ceilometer entries[DONE]Preparing Aodh entries[DONE]Preparing Puppet manifests[DONE]Copying Puppet modules and manifests[DONE]Applying192.168.108.10_controller.pp Testingifpuppet apply is finished:192.168.108.10_controller.pp[|]安装过程中会在Testing if …controller.pp步骤停留很长时间预计40-50分钟其他步骤很快。安装完成登录测试开启network服务controller:# 启动network服务[rootcontroller ~]# systemctl start network# 设置network服务开机自启[rootcontroller ~]# systemctl enable networknetwork.service is not a native service, redirecting to systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-installenablenetworkcompute:# 启动network服务[rootcompute ~]# systemctl start network# 设置network服务开机自启[rootcompute ~]# systemctl enable networknetwork.service is not a native service, redirecting to systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-installenablenetwork配置OpenStack命令补全#将命令写入到/etc/bash_completion.d/路径一定要写正确# 配置OpenStack命令自动补全[rootcontroller ~]# openstack complete /etc/bash_completion.d/completeTheopenstack bgp speaker show dragentsCLI is deprecated and will be removedinthe future. Useopenstack bgp dragent listCLI instead.关机拍快照openstack_controller和openstack_compute两个拍摄快照至此安装结束k.service is not a native service, redirecting to systemd-sysv-install.Executing: /usr/lib/systemd/systemd-sysv-install enable network