5.1.配置域名解析
1)配置主机名
# 主机名设置好就不能修改,否则会出问题,控制节点和计算节点配置相同,且都需要配置
# 在计算节点上执行 hostnamectl set-hostname compute1 echo ' # controller 192.168.182.143 controller # compute1 192.168.182.142 compute1 '>>/etc/hosts
5.2.关闭防火墙和selinux
systemctl stop firewalld.service systemctl disable firewalld.service systemctl status firewalld.service setenforce 0 getenforce sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux grep SELINUX=disabled /etc/sysconfig/selinux
5.3.配置时间同步
1)在计算节点配置时间同步服务
# 安装时间同步的软件包
yum install chrony -y
2)编辑配置文件确认有以下配置
vim /etc/chrony.conf # 在计算节点上配置 # 去掉原有的server server 192.168.182.143 iburst
3)重启chronyd服务,并配置开机自启动
systemctl restart chronyd.service
systemctl status chronyd.service
systemctl enable chronyd.service
systemctl list-unit-files |grep chronyd.service
4)设置时区,首次同步时间
timedatectl set-timezone Asia/Shanghai chronyc sources timedatectl status
5.4.配置相关yum源
1)配置阿里云的base和epel源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
2)安装openstack-rocky的仓库
# 很显然,计算节点也需要安装openstack的yum源
yum install centos-release-openstack-rocky -y
yum clean all
yum makecache
3)更新软件包
yum update -y
4)安装openstack客户端相关软件
yum install python-openstackclient openstack-selinux -y
# 至此,openstack计算节点的系统环境配置完成,虚拟机的话可以做下快照
5.5.安装nova计算节点相关软件包
1)计算节点安装nova软件包
mkdir /server/tools -p && cd /server/tools
yum install openstack-nova-compute python-openstackclient openstack-utils -y
2)快速修改配置文件(/etc/nova/nova.conf)
openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 192.168.182.142 openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron True openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver openstack-config --set /etc/nova/nova.conf DEFAULT enabled_apis osapi_compute,metadata openstack-config --set /etc/nova/nova.conf DEFAULT transport_url rabbit://openstack:openstack@controller openstack-config --set /etc/nova/nova.conf api auth_strategy keystone openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url http://controller:5000/v3 openstack-config --set /etc/nova/nova.conf keystone_authtoken memcached_servers controller:11211 openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_type password openstack-config --set /etc/nova/nova.conf keystone_authtoken project_domain_name default openstack-config --set /etc/nova/nova.conf keystone_authtoken user_domain_name default openstack-config --set /etc/nova/nova.conf keystone_authtoken project_name service openstack-config --set /etc/nova/nova.conf keystone_authtoken username nova openstack-config --set /etc/nova/nova.conf keystone_authtoken password nova openstack-config --set /etc/nova/nova.conf vnc enabled True openstack-config --set /etc/nova/nova.conf vnc server_listen 0.0.0.0 openstack-config --set /etc/nova/nova.conf vnc server_proxyclient_address '$my_ip' openstack-config --set /etc/nova/nova.conf vnc novncproxy_base_url http://controller:6080/vnc_auto.html openstack-config --set /etc/nova/nova.conf glance api_servers http://controller:9292 openstack-config --set /etc/nova/nova.conf oslo_concurrency lock_path /var/lib/nova/tmp openstack-config --set /etc/nova/nova.conf placement region_name RegionOne openstack-config --set /etc/nova/nova.conf placement project_domain_name Default openstack-config --set /etc/nova/nova.conf placement project_name service openstack-config --set /etc/nova/nova.conf placement auth_type password openstack-config --set /etc/nova/nova.conf placement user_domain_name Default openstack-config --set /etc/nova/nova.conf placement auth_url http://controller:5000/v3 openstack-config --set /etc/nova/nova.conf placement username placement openstack-config --set /etc/nova/nova.conf placement password placement
# 查看生效的配置:
egrep -v "^#|^$" /etc/nova/nova.conf
3)配置虚拟机的硬件加速
# 首先确定您的计算节点是否支持虚拟机的硬件加速。
egrep -c '(vmx|svm)' /proc/cpuinfo
# 如果返回位0,表示计算节点不支持硬件加速,需要配置libvirt使用QEMU方式管理虚拟机,使用以下命令:
openstack-config --set /etc/nova/nova.conf libvirt virt_type qemu egrep -v "^#|^$" /etc/nova/nova.conf|grep 'virt_type'
# 如果返回为其他值,表示计算节点支持硬件加速且不需要额外的配置,使用以下命令:
openstack-config --set /etc/nova/nova.conf libvirt virt_type kvm egrep -v "^#|^$" /etc/nova/nova.conf|grep 'virt_type'
4)启动nova相关服务,并配置为开机自启动
# 需要启动2个服务
systemctl start libvirtd.service openstack-nova-compute.service systemctl status libvirtd.service openstack-nova-compute.service systemctl enable libvirtd.service openstack-nova-compute.service systemctl list-unit-files |grep libvirtd.service systemctl list-unit-files |grep openstack-nova-compute.service
5)将计算节点增加到cell数据库
# 以下命令在控制节点操作:
cd /server/tools
source keystone-admin-pass.sh
# 检查确认数据库有新的计算节点(控制节点)
openstack compute service list --service nova-compute
# 手动将新的计算节点添加到openstack集群(控制节点)
[root@controller ~]# su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova Found 2 cell mappings. Skipping cell0 since it does not contain hosts. Getting computes from cell 'cell1': 61bfac3f-3bf8-4fd1-95d4-771e4ac69aab Found 0 unmapped computes in cell: 61bfac3f-3bf8-4fd1-95d4-771e4ac69aab
# 至此,计算节点安装完毕,接下来需要进行测试,检查nova节点的状态
5.6.在控制节点进行验证
1)应用管理员环境变量脚本
cd /server/tools
source keystone-admin-pass.sh
2)列表查看安装的nova服务组件
# 验证是否成功注册并启动了每个进程
openstack compute service list
3)在身份认证服务中列出API端点以验证其连接性
openstack catalog list
4)在镜像服务中列出已有镜像已检查镜像服务的连接性
openstack image list
5)检查nova各组件的状态
# 检查placement API和cell服务是否正常工作
nova-status upgrade check
~~~至此,nova计算节点,安装完毕并添加到openstack集群中~~~