本次实验我们将虚拟机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\ mtu 1500 inet 192.168.1.192 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::20c:29ff\:fe3d\:b305 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:3d\:b3:05 txqueuelen 1000 (Ethernet) RX packets 2 bytes 120 (120.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 22 bytes 3551 (3.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 网络正常启动,访问正常。

参考链接如下:

https://blog.csdn.net/u013248434/article/details/70276328

https://www.cnblogs.com/yxlblogs/p/11318200.html

https://www.cnblogs.com/hujiapeng/p/6991824.html

Copyright © https://yan-jian.com 2023 all right reserved更新时间: 2024-10-16 16:33:21

results matching ""

    No results matching ""