虚机迁移
在一台宿主机A迁移到另外一台宿主机B需要一下三步
1. 在宿主机A查看源文件格式和大小
[root@hostA img]# qemu-img info VM-2.img
image: VM-2.img
file format: qcow2
virtual size: 20G (21474836480 bytes)
2. 在另外一台宿主机创建新镜像
[root@hostB img]# qemu-img create -f qcow2 VM-2.img 20G
Formatting 'VM-2.img', fmt=qcow2 size=21474836480 encryption=off cluster_size=65536 lazy_refcounts=off
3. 热迁移虚机
[root@hostA img]virsh migrate --live --p2p --copy-storage-inc VM-2 qemu+tcp://$ip_B/system --verbose
常见问题
1. Could not open file: Permission denied
[root@hostA img]# virsh migrate --live --p2p --copy-storage-inc VM-2 qemu+tcp://$ip_B//system --verbose
error: internal error: process exited while connecting to monitor: Warning: option deprecated, use lost_tick_policy property of kvm-pit instead.
qemu-kvm: -drive file=/home/img/VM-2.img,if=none,id=drive-virtio-disk0,format=qcow2,cache=none: could not open disk image /home/img/VM-2.img: Could not open file: Permission denied
文件权限问题,chmod -R a+rw /home/img/
2. address resolution failed
[root@hostA img]# virsh migrate --live --p2p --copy-storage-inc VM-2 qemu+tcp://$ip_B/system --verbose
error: internal error: unable to execute QEMU command 'drive-mirror': address resolution failed for $$$$(server name of B):49153: Name or service not known
在/etc/hosts添加B对应的ip