KVM虚拟机需要从一台服务器迁移至另外一台服务器
- 查看磁盘位置并拷贝磁盘
源主机操作
磁盘位置需要和原始位置一致负责需要修改xml配置文件
# virsh domblklist centos_template
virsh domblklist centos_template
目标 源
------------------------------------
hda /kvm/centos_template.qcow2
hdb -
# scp /kvm/centos_template.qcow2 root@192.168.3.201:/kvm
- 查看xml配置文件并拷贝
源主机操作
# virsh dumpxml centos_template > centos_template.xml
# scp centos_template.xml root@192.168.3.201:/etc/libvirt/qemu
- 定义虚拟机
目标主机操作
# virsh define /etc/libvirt/qemu/centos_template.xml
- 启动虚拟机
目标主机操作
需要和源主机有相同的网络配置,例如配置了相同的虚拟桥接网卡br0,否则无法启动会报以下错误
# virsh start centos_template
错误:开始域 centos_template 失败
错误:无法在 'br0' 获取接口 MTU: 没有那个设备
启动
# virsh start centos_template