标签:kvm虚拟机迁移
KVM虚拟机迁移
说明:测试使用的是从本地到本地,远程方法类似,scp拷贝配置文件和虚拟磁盘即可,如果多块磁盘,都得拷贝,远程拷贝不需要修改配置文件,除非有相同的虚拟机,本例在本地,所以必须修改配置文件,否则会名称、uuid、目录等有冲突
1、关闭daixuan2虚拟机
[root@daixuan ~]# virsh shutdown daixuan2
域 daixuan2 被关闭
2、拷贝配置文件
[root@daixuan ~]# virsh dumpxml daixuan2 > /etc/libvirt/qemu/daixuan9.xml
[root@daixuan ~]# virsh domblklist daixuan2
Target Source
------------------------------------------------
vda /data/daixuan2.qcow2
3、拷贝虚拟磁盘文件,如果是两块磁盘,都得拷贝,配置文件中两块磁盘daixuan1都修改daixuan9
[root@daixuan ~]# rsync -avP /data/daixuan2.qcow2 /data/daixuan9.qcow2
sending incremental file list
daixuan2.qcow2
10829037568 100% 72.72MB/s 0:02:22 (xfer#1, to-check=0/1)
sent 10830359552 bytes received 31 bytes 76002523.39 bytes/sec
total size is 10829037568 speedup is 1.00
4、修改配置文件
[root@daixuan ~]# vi /etc/libvirt/qemu/daixuan8.xml
<name>daixuan2</name>
<uuid>82c8eda7-c875-18bb-34e3-3478c038cd30</uuid>
<source file=‘/data/daixuan2.qcow2‘/>
<name>daixuan9</name>
<uuid>82c8eda7-c875-18bb-34e3-3478c038bc38</uuid>
<source file=‘/data/daixuan9.qcow2‘/>
5、定义daixuan9域
[root@daixuan ~]# virsh define /etc/libvirt/qemu/daixuan9.xml
定义域 daixuan9(从 /etc/libvirt/qemu/daixuan9.xml)
[root@daixuan ~]# virsh list --all
Id 名称 状态
----------------------------------------------------
22 daixuan4 running
- daixuan1 关闭
- daixuan2 关闭
- daixuan3 关闭
- daixuan5 关闭
- daixuan9 关闭
6、登录daixuan9虚拟机
[root@daixuan ~]# virsh start daixuan9 --console
本文出自 “daixuan” 博客,请务必保留此出处http://daixuan.blog.51cto.com/5426657/1743492
标签:kvm虚拟机迁移
原文地址:http://daixuan.blog.51cto.com/5426657/1743492