本次实验我们将虚拟机10.1.100.224从宿主机10.1.100.34迁移至10.1.100.31上,并成功启动
1、KVM宿主机源节点环境(10.1.100.34)
[root\@10.1.100.34:]~$ virsh list --all
Id Name State
1 centos7.8-ldap(10.1.100.224) running
2、KVM宿主机目标节点环境(10.1.100.31)
[root\@10.1.100.31:]~$ virsh list --all
Id Name State
1 ubuntu20.04-ip-it(10.1.100.199) running
2 ubuntu20.04.5-postfix(10.1.100.205) running
6 ubuntu20.04-php(10.1.100.208) running
ubuntu18.04-desktop(10.1.100.212) shut off
ubuntu20.04-2-ansible(10.1.100.202) shut off
ubuntu20.04-2-desktop(10.1.100.211) shut off
ubuntu20.04-jenkins(10.1.100.204) shut off
ubuntu20.04-zabbix(10.1.100.200) shut off
ubuntu20.04-zabbix(10.1.100.201) shut off
ubuntu20.04.5-ELK(10.1.100.207) shut off
winserver-2009(10.1.100.203) shut off
3、开始迁移
①.关闭KVM虚拟机
[root\@10.1.100.34 ~]# virsh destroy “centos7.8-ldap(10.1.100.224)”
- Domain centos7.8-ldap(10.1.100.224) destroyed
[root\@10.1.100.34 ~]# virsh list --all
Id Name State
- centos7.8-ldap(10.1.100.224) shut off
[root\@10.1.100.34 ~]# virsh domblklist "centos7.8-ldap(10.1.100.224)"
#查看虚拟机所对应的磁盘文件路径
Target Source
vda /home/images/centos7.8-ldap(10.1.100.224) sda
②.拷贝KVM虚拟机的配置文件和磁盘文件到目标节点
[root\@10.1.100.34 ~]# scp /home/images/centos7.8-ldap(10.1.100.224).qcow2 10.1.100.31:/home/images/
[root\@10.1.100.34 ~]# scp /etc/libvirt/qemu/centos7.8-ldap(10.1.100.224).xml 10.1.100.31:/etc/libvirt/qemu/
③.目标节点导入虚拟机
[root\@10.1.100.31 ~]# virsh define /etc/libvirt/qemu/centos7.8-ldap(10.1.100.224).xml
[root\@10.1.100.31 ~]# virsh list --all
Id Name State
- centos7.8-ldap(10.1.100.224) shut off
④.模板节点启动虚拟机并测试
[root\@10.1.100.31 ~]# virsh start centos7.8-ldap(10.1.100.224)
- Domain centos7.8-ldap(10.1.100.224) started
[root\@10.1.100.31 ~]# virsh list --all
Id Name State
1 centos7.8-ldap(10.1.100.224) running
4、克隆后虚拟机网络不通解决方法:
Google一下吧,偶然看到一个文章,大意是跟系统自带的NetworkManager这个管理套件有关系,关掉就可以解决。 试一下:
systemctl stop NetworkManager
systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
重新启动网络:
systemctl start network.service
ifconfig |grep eno
eno16777736: flags=4163\
参考链接如下:
https://blog.csdn.net/u013248434/article/details/70276328