1.node节点扩容
#因此环境仅部署了一个compute节点,因此扩容一个compute计算节点
#计算节点安装服务:#提前将 yum 仓库、防火墙、selinux、主机名、时间同步等配置完毕。
[root@openstack-compute2 ~]#yum install centos-release-openstack-train -y
[root@openstack-compute2 ~]#yum install -y https://rdoproject.org/repos/rdo-release.rpm
[root@openstack-compute2 ~]#yum install python-openstackclient openstack-selinux -y
#安装nova-compute和neutron-compute的提供者网络的包
[root@openstack-compute2 ~]#yum install openstack-nova-compute -y
[root@openstack-compute2 ~]#yum install openstack-neutron-linuxbridge ebtables ipset -y
#拷贝nova-compute和neutron-compute的配置文件
[root@openstack-compute1 ~]# scp /etc/sysctl.conf 10.0.0.108:/etc
[root@openstack-compute1 ~]# scp /etc/neutron/neutron.conf 10.0.0.108:/etc/neutron/neutron.conf
[root@openstack-compute1 ~]#scp /etc/neutron/plugins/ml2/linuxbridge_agent.ini 10.0.0.108:/etc/neutron/plugins/ml2/linuxbridge_agent.ini
[root@openstack-compute2 ~]# mkdir /etc/nova
[root@openstack-compute1 ~]#scp /etc/nova/nova.conf 10.0.0.108:/etc/nova/nova.conf
#修改配置文件,vnc为自己的地址。
[root@openstack-compute2 ~]# vim /etc/nova/nova.conf
server_proxyclient_address = 10.0.0.108
[root@openstack-compute2 ~]# vim /etc/hosts
10.0.0.188 openstack-vip.tan.local
#计算节点启动服务:
[root@openstack-compute2 ~]# systemctl enable openstack-nova-compute.service
[root@openstack-compute2 ~]# systemctl restart openstack-nova-compute.service
[root@openstack-compute2 ~]# systemctl enable neutron-linuxbridge-agent libvirtd.service
[root@openstack-compute2 ~]# systemctl restart neutron-linuxbridge-agent libvirtd.service
#验证节点已经加入到集群。
[root@openstack-controller1 ~]# nova service-list
+--------------------------------------+----------------+---------------------------------+----------+---------+-------+----------------------------+-----------------+-------------+
| Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason | Forced down |
+--------------------------------------+----------------+---------------------------------+----------+---------+-------+----------------------------+-----------------+-------------+
| d2c9f15a-d8e6-472d-8950-f5d7b56be512 | nova-conductor | openstack-controller1.tan.local | internal | enabled | up | 2022-09-21T13:11:32.000000 | - | False |
| 54829f2e-4aa7-44cf-85fc-9dbee8ffa60b | nova-scheduler | openstack-controller1.tan.local | internal | enabled | up | 2022-09-21T13:11:24.000000 | - | False |
| 523bf526-6aac-4fac-a904-aa9c36df7e74 | nova-compute | openstack-compute1.tan.local | nova | enabled | up | 2022-09-21T13:11:27.000000 | - | False |
| 0913af81-7ad8-4136-854c-c5315834176e | nova-compute | openstack-compute2.tan.local | nova | enabled | up | 2022-09-21T13:11:32.000000 | - | False |
+--------------------------------------+----------------+---------------------------------+----------+---------+-------+----------------------------+-----------------+-------------+
[root@openstack-controller1 ~]# neutron agent-list
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
+--------------------------------------+--------------------+---------------------------------+-------------------+-------+----------------+---------------------------+
| id | agent_type | host | availability_zone | alive | admin_state_up | binary |
+--------------------------------------+--------------------+---------------------------------+-------------------+-------+----------------+---------------------------+
| 4d78d03b-2691-4072-ae6a-f09cd8af3603 | Linux bridge agent | openstack-compute1.tan.local | | :-) | True | neutron-linuxbridge-agent |
| 59390685-4dae-487d-9e15-f0cdf1709ffe | DHCP agent | openstack-controller1.tan.local | nova | :-) | True | neutron-dhcp-agent |
| 5ab3fb3b-4f38-41aa-a750-b558d98e3a38 | Linux bridge agent | openstack-controller1.tan.local | | :-) | True | neutron-linuxbridge-agent |
| 8dfaf895-002c-470c-9736-89ac0696454e | Metadata agent | openstack-controller1.tan.local | | :-) | True | neutron-metadata-agent |
| f2e9c598-e6ea-494d-a550-07aa33d29bef | Linux bridge agent | openstack-compute2.tan.local | | :-) | True | neutron-linuxbridge-agent |
+--------------------------------------+--------------------+---------------------------------+-------------------+-------+----------------+---------------------------+
2.虚拟机动态调整实例大小及跨主机迁移
#配置优化nova
[root@openstack-controller1 ~]# vim /etc/nova/nova.conf
#虚拟机自动启动
resume_guests_state_on_host_boot=true
#cpu超限8倍
cpu_allocation_ratio=8
#内存1.5倍
ram_allocation_ratio=1.5
#磁盘1倍,不超限使用
disk_allocation_ratio=1.0
#配置虚拟机类型动态调整
allow_resize_to_same_host=true
#保留磁盘给系统使用
reserved_host_disk_mb=20480
#保留内存给系统使用
reserved_host_memory_mb=4096
[root@openstack-controller1 ~]# bash nova_restart.sh
[root@openstack-compute2 ~]# vim /etc/nova/nova.conf
#一样配置这几项
[root@openstack-compute1 ~]# systemctl restart openstack-nova-compute.service
[root@openstack-compute2 ~]# systemctl restart openstack-nova-compute.service
#:各计算节点配置 nova 用户: 将 shell 改为/bin/bash
[root@openstack-compute1 ~]# usermod nova -s /bin/bash
[root@openstack-compute2 ~]# usermod nova -s /bin/bash
#配置 nova 登录密码:
[root@openstack-compute1 ~]# echo 123456 | passwd --stdin nova
[root@openstack-compute2 ~]# echo 123456 | passwd --stdin nova
#切换至 nova 用户获取秘钥,然后将秘钥相互 copy 至各个计算节点:
[root@openstack-compute1 ~]# su - nova
[nova@openstack-compute1 ~]$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_dsa >/dev/null 2>&1
[nova@openstack-compute1 ~]$ ssh-copy-id -i .ssh/id_dsa.pub [email protected]
[nova@openstack-compute1 ~]$ ssh 10.0.0.108
Last login: Wed Sep 21 21:49:50 2022 from 10.0.0.107
[nova@openstack-compute2 ~]$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_dsa >/dev/null 2>&1
[nova@openstack-compute2 ~]$ ssh-copy-id -i .ssh/id_dsa.pub [email protected]
#创建实例类型more,cpu,内存,磁盘更大。
#登录http://openstack-vip.tan.local/dashboard/project/instances/,在项目--实例--编辑实例--调整实例大小,从centos-template变更为more类型。稍等一会,确认调整大小/迁移
#查看日志验证虚拟机迁移到compute2节点了
[root@openstack-compute2 ~]# cat /var/log/nova/nova-compute.log |grep compute2
2022-09-21 21:08:15.966 3723 INFO nova.compute.resource_tracker [req-3fd1fdea-3861-4cdc-981e-0d8dd37af990 - - - - -] Compute node record created for openstack-compute2.tan.local:openstack-compute2.tan.local with uuid: ab29de6a-62f3-4402-96fc-f90d342d38d6
2022-09-21 21:08:16.209 3723 INFO nova.scheduler.client.report [req-3fd1fdea-3861-4cdc-981e-0d8dd37af990 - - - - -] [req-7966059a-d8d8-4a3b-a4fc-fdd974427396] Created resource provider record via placement API for resource provider with UUID ab29de6a-62f3-4402-96fc-f90d342d38d6 and name openstack-compute2.tan.local.
2022-09-21 21:55:01.368 26610 INFO nova.compute.claims [req-53addd9d-add9-4d5e-8f26-100d53b87c29 317a4ea405d745bbb9e5d76fc87a0751 f7c80417780a4bd59beaa38a9d36271e - default default] [instance: af9ef6f1-6eb9-4a8b-9c65-995f383a9b76] Claim successful on node openstack-compute2.tan.local
![](/i/l/?n=22&i=blog/1914165/202209/1914165-20220926143038875-1129738668.png)
![](/i/l/?n=22&i=blog/1914165/202209/1914165-20220926143053009-715662914.png)
![](/i/l/?n=22&i=blog/1914165/202209/1914165-20220926143112279-945934070.png)
![](/i/l/?n=22&i=blog/1914165/202209/1914165-20220926143117769-1600639819.png)
标签:跨机,compute,虚拟机,nova,compute2,openstack,root,neutron From: https://www.cnblogs.com/tanll/p/17746602.html