使用Packstack安装单节点OpenStack
作者:Guangran 日期:2023-05-14
环境准备
硬件准备
- 内存:大于 6G,越大越好
- CPU:大于 4核,越多越好
- 存储:大于 100G,越大越好
- 网络:至少一个接口,且可以访问互联网
- 类型:物理机或虚拟机
软件准备
- 操作系统:CentOS-7-x86_64-DVD-2009
- OpenStack 版本:OpenStack-train
前期配置
安装操作系统
最小化安装 CentOS 7.9
关闭 SELinux
临时关闭
TERMINALbash
[root@localhost ~]# setenforce 0修改配置文件,永久关闭
TERMINALbash
[root@localhost ~]# vi /etc/selinux/config设置 SELINUX 为 disabled
TERMINALbash
# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUX=disabled# SELINUXTYPE= can take one of three values:# targeted - Targeted processes are protected,# minimum - Modification of targeted policy. Only selected processes are protected.# mls - Multi Level Security protection.SELINUXTYPE=targeted关闭防火墙
关闭防火墙并设置防火墙为开机不启动
TERMINALbash
[root@localhost ~]# systemctl stop firewalld[root@localhost ~]# systemctl disable firewalld修改网卡名称并配置网络
Point
此处需要将网卡的名称修改为eth0,如果网卡名称默认为eht0则只需要配置网络。
重命名网卡配置文件
TERMINALbash
[root@localhost ~]# cd /etc/sysconfig/network-scripts/[root@localhost network-scripts]# mv ifcfg-ens32 ifcfg-eth0编辑网卡配置文件
TERMINALbash
[root@localhost network-scripts]# vi ifcfg-eth0TERMINALbash
TYPE=EthernetBOOTPROTO=static # IP 地址为静态配置NAME=eth0DEVICE=eth0 # 网卡设备名ONBOOT=yesIPADDR=172.16.8.100 # IP地址NETMASK=255.255.255.0 # 子网掩码GATEWAY=172.16.8.2 # 网关DNS1=114.114.114.114 # 主 DNS关闭网络管理软件 NetworkManager
TERMINALbash
[root@localhost ~]# systemctl stop NetworkManager[root@localhost ~]# systemctl disable NetworkManager修改开机引导文件
TERMINALbash
[root@localhost ~]# vi /etc/default/grub在 spectre_v2=retpoline 后新增 net.ifnames=0 biosdevname=0
TERMINALbash
GRUB_TIMEOUT=5GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"GRUB_DEFAULT=savedGRUB_DISABLE_SUBMENU=trueGRUB_TERMINAL_OUTPUT="console"GRUB_CMDLINE_LINUX="crashkernel=auto spectre_v2=retpoline net.ifnames=0 biosdevname=0 rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"GRUB_DISABLE_RECOVERY="true"重新生成 GRUB 并更新内核参数
TERMINALbash
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg配置 yum 软件源
删除已有的 repo 文件
TERMINALbash
[root@localhost ~]# cd /etc/yum.repos.d/[root@localhost ~]# rm -fr *下载在线源文件(这里使用的阿里云的镜像源)
TERMINALbash
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo更新缓存
TERMINALbash
[root@localhost yum.repos.d]# yum clean all[root@localhost yum.repos.d]# yum makecache安装基本软件
TERMINALbash
[root@localhost ~]# yum install -y bash-completion vim net-tools wget ntpdate配置时间同步
这里使用的是阿里云的 NTP 授时服务器
TERMINALbash
[root@localhost ~]# ntpdate ntp.aliyun.com修改主机名和配置 hosts 文件
TERMINALbash
[root@localhost ~]# hostnamectl set-hostname controller[root@localhost ~]# bash[root@controller ~]# vim /etc/hostsTERMINALbash
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6172.16.8.100 controller开始安装
配置 RDO-OpenStack 软件源
配置 epel 源
TERMINALbash
[root@controller ~]# wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo配置 RDO 源
TERMINALbash
[root@controller ~]# yum install -y https://rdoproject.org/repos/rdo-release.rpm[root@controller ~]# vim /etc/yum.repos.d/rdo-release.repo TERMINALbash
[openstack-train]name=OpenStack Train Repositorybaseurl=https://mirrors.aliyun.com/centos/7.9.2009/cloud/$basearch/openstack-train/# mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=cloud-openstack-traingpgcheck=1enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud更新缓存
TERMINALbash
[root@controller ~]# yum clean all[root@controller ~]# yum makecache查看软件缓存列表
TERMINALbash
[root@controller ~]# yum repolistLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* rdo-qemu-ev: mirrors.163.com* updates: mirrors.aliyun.comrepo id repo name statusbase/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,756extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 512openstack-train/x86_64 OpenStack Train Repository 3,168rdo-qemu-ev/x86_64 RDO CentOS-7 - QEMU EV 63updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 4,101repolist: 31,672安装依赖包
安装 leatherman 1.3.0-9.el7
TERMINALbash
[root@controller ~]# yum install -y leatherman-1.3.0-9.el7.x86_64[root@controller ~]# rpm -q leathermanleatherman-1.3.0-9.el7.x86_64安装 python2-qpid-proton-0.26.0-2.el7.x86_64
TERMINALbash
[root@controller ~]# yum install -y python2-qpid-proton-0.26.0-2.el7.x86_64[root@controller ~]# rpm -q python2-qpid-proton-0.26.0-2.el7.x86_64python2-qpid-proton-0.26.0-2.el7.x86_64安装 packstack
TERMINALbash
[root@controller ~]# yum install -y openstack-packstack生成 RDO 应答文件
TERMINALbash
[root@controller ~]# packstack --gen-answer-file=/root/openstack.iniAdditional information:* Parameter CONFIG_NEUTRON_L2_AGENT: You have chosen OVN Neutron backend. Note that this backend does not support the VPNaaS or FWaaS services. Geneve will be used as the encapsulation method for tenant networks[root@controller ~]# lsanaconda-ks.cfg openstack.ini编辑应答文件
TERMINALbash
[root@controller ~]# vim openstack.ini按照以下内容对 openstack.ini 文件进行修改,除修改以下所列项外,其他项不保持变(密码字段,可根据需要自行修改,这里全部配置为了 123456)
TERMINALbash
CONFIG_DEFAULT_PASSWORD=123456CONFIG_AODH_INSTALL=nCONFIG_MARIADB_USER=rootCONFIG_MARIADB_PW=123456CONFIG_KEYSTONE_DB_PW=123456CONFIG_KEYSTONE_ADMIN_EMAIL=root@localhostCONFIG_KEYSTONE_ADMIN_USERNAME=adminCONFIG_KEYSTONE_ADMIN_PW=123456CONFIG_NEUTRON_ML2_TYPE_DRIVERS=vxlan,flatCONFIG_NEUTRON_ML2_TENANT_NETWORK_TYPES=vxlanCONFIG_NEUTRON_ML2_MECHANISM_DRIVERS=openvswitchCONFIG_NEUTRON_L2_AGENT=openvswitchCONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=extnet:br-exCONFIG_NEUTRON_OVS_BRIDGE_IFACES=br-ex:eth0CONFIG_NEUTRON_OVS_EXTERNAL_PHYSNET=extnetCONFIG_PROVISION_DEMO=n开始安装
使用编辑好的应答文件进行安装
TERMINALbash
[root@controller ~]# packstack --answer-file=/root/openstack.iniWelcome to the Packstack setup utilityThe installation log file is available at: /var/tmp/packstack/20220809-155808-CJshER/openstack-setup.logInstalling: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 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 Swift builder entries [ DONE ]Preparing Swift proxy entries [ DONE ]Preparing Swift storage 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 ]Applying 172.16.8.100_controller.pp172.16.8.100_controller.pp: [ DONE ]Applying 172.16.8.100_network.pp172.16.8.100_network.pp: [ DONE ]Applying 172.16.8.100_compute.pp172.16.8.100_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 172.16.8.100. To use the command line tools you need to source the file.* To access the OpenStack Dashboard browse to http://172.16.8.100/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/20220809-155808-CJshER/openstack-setup.log* The generated manifests are available at: /var/tmp/packstack/20220809-155808-CJshER/manifests验证安装
命令行
导入 OpenStack 访问密钥
TERMINALbash
[root@controller ~]# source keystonerc_admin查看 Nova 组件服务
TERMINALbash
[root@controller ~(keystone_admin)]# nova service-list
查看服务列表
TERMINALbash
[root@controller ~(keystone_admin)]# openstack service list+----------------------------------+------------+--------------+| ID | Name | Type |+----------------------------------+------------+--------------+| 29b3be88324449118440cd72c1bdc674 | cinderv3 | volumev3 || 36ca1b3ef5f44c22951283ecf157d02b | neutron | network || 5403e654121c4690a28a4b0970857993 | swift | object-store || a6b4198b645d415e9b1a8123cb088078 | aodh | alarming || bf2149be65344b94aee5ed59f4ae4d9f | nova | compute || cc39a43522e04d43967a2328d8dab935 | glance | image || d82544dd2cfe4edc81877b8e7a0dcda6 | ceilometer | metering || e07efd435825458e907e3681881fe27d | keystone | identity || e9139dc2a30c440b88208de0ca0b78f6 | gnocchi | metric || ea42fb99e1b542e289105f111f15bc17 | placement | placement || f019f96acff9429a965770bb099687d0 | cinderv2 | volumev2 |+----------------------------------+------------+--------------+访问 dashboard
打开浏览器,访问 http://172.16.8.100/dashboard

输入账号: admin 密码:123456 登录
