KVM Live Migration Example with Two Hosts

Mindwatering Incorporated

Author: Tripp W Black

Created: 12/11/2019 at 09:41 PM

 

Category:
Linux
KVM

Task:
Map NFS store on Ubuntu hosts.
Migrate VM from host to second host using live migration.

Prerequisites:
Have a NFS or iSCSI storage available. (e.g. NSF store with address: 192.168.33.16 sharing /nfsstore01 )
Have two or more KVM hosts available with KVM installed. (e.g. KVMHost01 @ 192.168.22.101, and KVMHost02 @ 192.168.22.102 )
Two hosts can resolve each other via DNS or /etc/hosts file.
Two hosts have same networks set up.

Steps:
1. Create a local folder on each host with same path to be share.
e.g. /local/vols/nfsstor01/
$ cd /local
$ sudo mkdir vols
$ cd vols
$ sudo mkdir nsfstor01

2. Test the NFS storage and then add to the /etc/fstab file.
Test with a temporary mount, and then add to fstab so it persists after a reboot.
$ sudo mount 192.168.33.16:/nfstore01 /local/vols/nfsstore01/

If you can see the files on the NFS store okay, and can change one, you are set to go.

Update the /etc/fstab file with:
...
192.168.33.16:/nfsstore01 /local/vols/nfsstore01/ nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0

When you can restart the host, do so to confirm the NFS fstab mapping loaded.

3. Perform a live migration:
(For this example, the VM's name is TestVM.)

root@kvmhost01:~# virsh list
<output lists the Id number and the Name of the VMs running and stopped on the host. It includes TestVM.>

root@kvmhost01:~# virsh migrate --live TestVM qemu+ssh://192.168.22.102/system
<enter root password>

Wait a bit, and do another list:
root@kvmhost01:~# virsh list
<output lists the VMs on the host, but TestVM is no longer listed>

Confirm the VM is on the second host:
root@kvmhost02:~# virsh list
<output lists the VMs running and stopped on the host. It includes TestVM.>


previous page

×