一.先决条件
云主机冷迁移,即:将一台云主机从一个计算节点上,迁移到另外一个计算节点上。因为环境原因,所以我们需要准备两个计算节点。
1.1准备环境
在控制节点上,安装一个计算节点
#在控制节点安装nova-compute
[root@linux-node1 ~]# yum install openstack-nova-compute –y
#在控制节点安装neutron及其组件
[root@linux-node1 ~]# yum install openstack-neutron-linuxbridge ebtables ipset –y
1.2修改nova配置文件
#修改配置文件
[root@linux-node1 ~]# vim /etc/nova/nova.conf
#配置VNC连接地址,打开注释
novncproxy_base_url=http://192.168.56.11:6080/vnc_auto.html
1.3启动nova-compute服务
#允许开机自启
[root@linux-node1 ~]# systemctl enable libvirtd.service openstack-nova-compute.service
#启动服务
[root@linux-node1 ~]# systemctl start libvirtd.service openstack-nova-compute.service
二.配置调整大小\冷迁移
2.1编辑nova配置文件(控制节点)
#编辑nova配置文件
[root@linux-node1 ~]# vinm /etc/nova/nova.conf
#将false改为true并打开注释
allow_resize_to_same_host=true
#打开注释
scheduler_default_filters=RetryFilter,AvailabilityZoneFilter,RamFilter,DiskFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter
2.2重启nova控制节点
#重启服务
[root@linux-node1 ~]# systemctl restart openstack-nova-api.service \
openstack-nova-consoleauth.service openstack-nova-scheduler.service \
openstack-nova-conductor.service openstack-nova-novncproxy.service
2.3修改计算节点nova配置文件
#编辑nova配置文件
[root@linux-node2 ~]# vinm /etc/nova/nova.conf
#将false改为true并打开注释
allow_resize_to_same_host=true
#打开注释
scheduler_default_filters=RetryFilter,AvailabilityZoneFilter,RamFilter,DiskFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter
2.4重启nova计算节点
[root@linux-node2 ~]# systemctl start libvirtd.service openstack-nova-compute.service
三.创建秘钥对
3.1允许nova用户登录
#查看nova用户状态
[root@linux-node1 ~]# cat /etc/passwd|grep nova
nova:x:::OpenStack Nova Daemons:/var/lib/nova:/sbin/nologin
#修改nova登录bash
[root@linux-node1 ~]# usermod -s /bin/bash nova
#查看修改后内容
[root@linux-node1 ~]# cat /etc/passwd|grep nova
nova:x:::OpenStack Nova Daemons:/var/lib/nova:/bin/bash
#给nova用户创建密码
[root@linux-node1 ~]# passwd nova
Changing password for user nova.
New password: nova
BAD PASSWORD: The password is shorter than characters
Retype new password: nova
passwd: all authentication tokens updated successfully.
3.2修改另一台计算节点
#查看nova用户状态
[root@linux-node2 ~]# cat /etc/passwd|grep nova
nova:x:::OpenStack Nova Daemons:/var/lib/nova:/sbin/nologin
#修改nova登录bash
[root@linux-node2 ~]# usermod -s /bin/bash nova
#查看修改后内容
[root@linux-node2 ~]# cat /etc/passwd|grep nova
nova:x:::OpenStack Nova Daemons:/var/lib/nova:/bin/bash
#给nova用户创建密码
[root@linux-node2 ~]# passwd nova
Changing password for user nova.
New password: nova
BAD PASSWORD: The password is shorter than characters
Retype new password: nova
passwd: all authentication tokens updated successfully.
3.3切换nova用户创建秘钥对
#切换用户
[root@linux-node1 ~]# su - nova
#创建秘钥对
-bash-4.2$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_dsa >/dev/null >&
3.4另一台计算节点操作
#切换用户
[root@linux-node2 ~]# su - nova
#创建秘钥对
-bash-4.2$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_dsa >/dev/null >&
3.5互相发送公钥
#在node1上给node2发送公钥
-bash-4.2$ ssh-copy-id -i .ssh/id_dsa.pub nova@192.168.56.12
#在node2上给node1发送公钥
-bash-4.2$ ssh-copy-id -i .ssh/id_dsa.pub nova@192.168.56.11
3.6测试是否可以面秘钥登录
-bash-4.2$ ssh 192.168.56.12
-bash-4.2$ ssh 192.168.56.11
四.调整云主机大小
五.云主机冷迁移
【开源是一种精神,分享是一种美德】
— By GoodCook
— 笔者QQ:253097001
— 欢迎大家随时来交流
—原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。