KVM虚拟机静态迁移 | IT运维网
  • 本站启用了账户登录密码错误就锁定模式,如有人误操作被锁请邮件(yvan.lu@ityww.cn)告知我账户名。
  • 本站为个人技术性站点,上面会更新一些系统、网络、虚拟化及云计算等相关的文章,与大家一起参考、学习和交流。
  • 欢迎访问本网站;本站QQ交流群:654792529;如果您觉得本站非常有看点,那么赶紧使用Ctrl+D收藏吧!

KVM虚拟机静态迁移

KVM yvan 7年前 (2018-01-14) 3667次浏览 已收录 0个评论 扫描二维码

静态迁移就是拷贝虚拟机(关机状态)的虚拟磁盘文件与配置文件到目标虚拟服务器上实现的迁移。

1、确保被迁移虚机处于关机状态并检查虚机磁盘列表

[root@sun ~]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 2     mercury                        running
 3     venus                          running
 4     aptcacher                      running
 -     pluto                          shut off

[root@sun ~]# virsh domblklist pluto
Target     Source
------------------------------------------------
hda        /var/lib/libvirt/images/pluto.qcow2
hdb        -

2、备份导出虚机配置文件:virsh dumpxml vhostname > vhostname.xml

[root@sun ~]# virsh dumpxml pluto > pluto.xml
[root@sun ~]# ll | grep pluto
-rw-r--r--  1 root root   3393 Oct 30 21:22 pluto.xml

3、将备份导出的虚机配置文件和虚机磁盘镜像拷贝至目标服务器相关位置

[root@sun ~]# scp pluto.xml root@172.16.2.100:/etc/libvirt/qemu/
The authenticity of host '172.16.2.100 (172.16.2.100)' can't be established.
ECDSA key fingerprint is e7:cb:b7:7c:26:36:de:61:50:3d:dd:b1:8b:ad:9e:4b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.2.100' (ECDSA) to the list of known hosts.
root@172.16.2.100's password:
pluto.xml                                          100% 3397     3.3KB/s   00:00
[root@sun ~]# scp /var/lib/libvirt/images/pluto.qcow2 root@172.16.2.100:/date/images
root@172.16.2.100's password:
pluto.qcow2                                            100%   23GB 108.7MB/s   03:40

4、在目标服务器上查看相关文件均已被拷贝过来

[root@boron3 ~]# ll /etc/libvirt/qemu
total 16
drwxr-xr-x 2 root root   27 Oct 30 15:06 autostart
-rw------- 1 root root 4643 Oct 30 16:26 centos7.0.xml
drwx------ 3 root root   42 Oct 29 16:35 networks
-rw-r--r-- 1 root root 3393 Oct 31 09:27 pluto.xml
[root@boron3 ~]# ll /date/images/ -h
total 25G
-rw------- 1 qemu qemu 21G Oct 31 09:30 centos7.0.qcow2
-rw-r--r-- 1 root root 24G Oct 31 09:06 pluto.qcow2

5、编辑修改虚机配置文件检查虚机磁盘文件存放位置

[root@boron3 ~]# vim /etc/libvirt/qemu/pluto.xml

KVM虚拟机静态迁移
6、定义注册虚拟主机:virsh define /etc/libvirt/qemu/pluto.xml

[root@boron3 ~]# virsh define /etc/libvirt/qemu/pluto.xml
Domain pluto defined from /etc/libvirt/qemu/pluto.xml

[root@boron3 ~]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 1     centos7.0                      running
 -     pluto                          shut off

7、开启虚机,检查各方面无误后表示迁移成功:virsh start pluto

[root@boron3 ~]# virsh start pluto
Domain pluto started
[root@boron3 ~]# virsh list
 Id    Name                           State
----------------------------------------------------
 1     pluto                          running
 2     centos7.0                      running

IT运维网 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明KVM虚拟机静态迁移
喜欢 (3)
yvan
关于作者:
聪明来自勤奋、知识在于积累、好记性不如烂键盘!

您必须 登录 才能发表评论!