确认两个节点的nova用户id一样:

保证两个节点的nova用户uid,gid相同,可使用id nova命令查看。


修改libvirt配置文件:

注意:两个节点都需要修改
[root@compute-1 ~]# egrep -v  '^$|^#' /etc/sysconfig/libvirtd
LIBVIRTD_CONFIG=/etc/libvirt/libvirtd.conf
LIBVIRTD_ARGS="--listen"

--------------------------------------------------------------------------------

[root@compute-2 ~]# egrep -v  '^$|^#' /etc/sysconfig/libvirtd
LIBVIRTD_CONFIG=/etc/libvirt/libvirtd.conf
LIBVIRTD_ARGS="--listen"
[root@compute-1 ~]# grep -vE '^#|^$' /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp = 1
auth_tcp = "none"

--------------------------------------------------------------------------------

[root@compute-2 ~]# grep -vE '^#|^$' /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp = 1
auth_tcp = "none"

重启libvirtd服务:

[root@compute-1 ~]# systemctl restart libvirtd.service
[root@compute-2 ~]# systemctl restart libvirtd.service
[root@compute-1 ~]# netstat -tunpl|grep 16509
tcp        0      0 0.0.0.0:16509           0.0.0.0:*               LISTEN      21666/libvirtd      
tcp6       0      0 :::16509                :::*                    LISTEN      21666/libvirtd

--------------------------------------------------------------------------------

[root@compute-2 ~]# netstat -tunpl|grep 16509
tcp        0      0 0.0.0.0:16509           0.0.0.0:*               LISTEN      20576/libvirtd      
tcp6       0      0 :::16509                :::*                    LISTEN      20576/libvirtd

测试下可否无密连接KVM:

[root@compute-1 ~]# virsh -c qemu+tcp://compute-2/system
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # exit

--------------------------------------------------------------------------------

[root@compute-2 ~]# virsh -c qemu+tcp://compute-1/system
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # exit

修改nova.conf配置文件:

注意:两个节点都需要修改
[root@compute-1 ~]# vim /etc/nova/nova.conf
[libvirt]
virt_type = qemu
inject_key = True
live_migration_flag = VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE
block_migration_flag = VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_NON_SHARED_INC
live_migration_downtime  =  500
live_migration_downtime_steps  =  10
live_migration_downtime_delay  =  75

--------------------------------------------------------------------------------

[root@compute-2 ~]# vim /etc/nova/nova.conf
[libvirt]
virt_type = qemu
inject_key = True
live_migration_flag = VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE
block_migration_flag = VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_NON_SHARED_INC
live_migration_downtime  =  500
live_migration_downtime_steps  =  10
live_migration_downtime_delay  =  75

重启nova服务:

[root@compute-1 ~]# systemctl restart openstack-nova-compute.service
[root@compute-2 ~]# systemctl restart openstack-nova-compute.service

开始实例热迁移:

不知为什么使用命令进行实例热迁移会没有效果,以下使用dashboard面板操作。