KVM : Storage Migration2025/01/17 |
|
This is the example to use Storage Migration feature for Virtual Machines. The different point of Storage Migration from the Common Live Migration is that Storage Migration does not need a Storage server that has Virtual Machine images, when executing Storage Migration, Virtual Machine image on a KVM host is migrated on another KVM host like follows.
Storage Migration
<------------------->
+----------------------+ +----------------------+
| [ KVM Host #1 ] |10.0.0.30 10.0.0.51| [ KVM Host #2 ] |
| +---------------------+ |
| kvm01.srv.world | | kvm02.srv.world |
+----------------------+ +----------------------+
|
| [1] |
Configure 2 KVM Host Server and Create a Virtual Machine on a KVM Host. |
| [2] | On KVM Hosts, if Firewalld is running, allow ports. |
|
[root@kvm01 ~]# firewall-cmd --add-service={libvirt,libvirt-tls} [root@kvm01 ~]# firewall-cmd --add-port=49152-49215/tcp [root@kvm01 ~]# firewall-cmd --runtime-to-permanent |
| [3] | Confirm the file size of a Virtual Machine image like follows on a KVM host, and next, move to another KVM host to create an empty disk image like follows. |
|
# show the size of Virtual machine [root@kvm01 ~]# qemu-img info /var/kvm/images/centos10.img
image: /var/kvm/images/centos10.img
file format: qcow2
virtual size: 20 GiB (21474836480 bytes)
disk size: 4.88 GiB
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
lazy refcounts: true
refcount bits: 16
corrupt: false
extended l2: false
Child node '/file':
filename: /var/kvm/images/centos10.img
protocol type: file
file length: 20 GiB (21478375424 bytes)
disk size: 4.88 GiB
Format specific information:
extent size hint: 1048576
### on another KVM host ### # create a disk which is the same size of a Virtual Machine [root@kvm02 ~]# qemu-img create -f qcow2 -o preallocation=falloc /var/kvm/images/centos10.img 21474836480 |
| [4] | That's OK, Run Storage Migration like follows. For connection between KVM Hosts, they connects to others with SSH, so it had better to set SSH key-pair with root account before running live migration. |
|
[root@kvm01 ~]# virsh start centos10 [root@kvm01 ~]# virsh list Id Name State -------------------------- 1 centos10 running
[root@kvm01 ~]#
[root@kvm01 ~]# virsh migrate --live --copy-storage-all centos10 qemu+ssh://kvm02.srv.world/system virsh list Id Name State -------------------- # running virtual machines have been moved
### on another KVM host ### [root@kvm02 ~]# virsh list Id Name State -------------------------- 2 centos10 running |
| Sponsored Link |
|
|