原文网址:http://www.server-world.info/en/note?os=CentOS_6&p=kvm&f=14
This is the example to use Storage Migration function for virtual machines.
本节演示了虚拟机存储迁移功能。
The different point of Storage Migration from
Live Migration is that Storage Migration does not need a Storage server which has virtual machine images, when executing
本节演示了虚拟机存储迁移功能。
存储迁移与在线迁移的不同点是:当执行迁移时,存储迁移不需要有一个存有虚拟机镜像的存储服务器。
Storage Migration, virtual machine image on a KVM host is migrated on another KVM host like follows.
存储迁移,将一台KVM主机上的虚拟机镜像迁移到另一台KVM主机上,如下图示:
Storage Migration <-------------------> +----------------------+ +----------------------+ | [ KVM Host #1 ] |10.0.0.21 10.0.0.22| [ KVM Host #2 ] | | +---------------------+ | | kvm01.server.world | | kvm02.server.world | +----------------------+ +----------------------+
1、Create a virtual machine on a KVM host.
在一个KVM主机上创建一个虚拟机镜像。
2、Show the file size of a virtual machine image like follows on a KVM host and move to another KVM host, create a empty disk space like follows.
按如下方式,在一个KVM主机上显示要迁移到另一个KVM主机上的虚拟机镜像文件的大小,按如下方式创建一个空磁盘空间。
# show the size of Virtual machine
[root@kvm01 ~]# ll /var/kvm/images
total 846468 -rwxr-xr-x 1 root root 32212254720 Aug 6 22:00 centos.img
### on another KVM host ###
# create a disk space which is the same size of a virtula machine
[root@kvm02 ~]#fallocate -l 32212254720 /var/kvm/images/centos.img
[root@kvm02 ~]# ll /var/kvm/images
total 31457284 -rw-r--r-- 1 root root 32212254720 Aug 6 22:10 centos.img3、It's OK all, execute Storage Migration like follows.
一切正常运行后,按如下方式执行存储器迁移:
[root@kvm01 ~]#virsh list
Id Name State -------------------------------------- 2 centos running
[root@kvm01 ~]#virsh migrate --live --copy-storage-all centos qemu+ssh://10.0.0.22/system
root@10.0.0.22's password:
[root@kvm01 ~]#virsh list
root@10.0.0.22's password:
Id Name State --------------------------------------
# just migrated
### on another KVM host ###
[root@kvm02 ~]#virsh list
Id Name State --------------------------------------- 1 centos running
# back to another host, it's OK to execute normal Live Migration
[root@kvm02 ~]#virsh migrate --live centos qemu+ssh://10.0.0.21/system
root@10.0.0.21's password:
Id Name State --------------------------------------