Home / Redhat Cluster / How to Perform Live Migration of KVM Guest in Redhat Cluster ?

How to Perform Live Migration of KVM Guest in Redhat Cluster ?

I got so many emails that how to configure the redhat cluster to migrate redhat virtual guest(KVM guests) from one cluster node to another and we have seen how to configure it in the previous post.Once the cluster configuration is done ,we are good to test the live migration.Before proceeding to the live migration,we will do some manual test by stopping the service(VM: KVM guest) in one cluster node and starting it in another.If you didn’t have the ssh keyless authentication configured for root between two cluster nodes, you will get below error messages in /var/log/messages.

Assumptions:
Virtual machine is installed in shared location and Redhat Cluster is configured with virtual guest.

1. Check the cluster status and service status.

[root@uagl1 ~]# clustat 
Cluster Status for uacl1 @ Thu Oct 24 22:44:00 2013
Member Status: Quorate

 Member Name          ID   Status
 ------ ----          ---- ------
 uagl1h               1    Online, Local, rgmanager
 uagl2h               2    Online, rgmanager

 Service Name             Owner (Last)             State         
 ------- ----             ----- ------             -----         
 vm:VMG                   uagl1h                   started       
[root@uagl1 ~]#


2.Check the virtual machine status.

[root@uagl1 ~]# virsh list
 Id    Name                           State
----------------------------------------------------
 26    VMG                            running

[root@uagl1 ~]#


3. Login to any of the cluster node and stop the service(vm:VMG).This will halt the virtual machine (KVM Guest)

[root@uagl1 ~]# clusvcadm -d vm:VMG
Local machine disabling vm:VMG...Success
[root@uagl1 ~]# virsh list
 Id    Name                           State
----------------------------------------------------

[root@uagl1 ~]# clustat 
Cluster Status for uacl1 @ Thu Oct 24 22:45:48 2013
Member Status: Quorate

 Member Name             ID   Status
 ------ ----             ---- ------
 uagl1h                   1   Online, Local, rgmanager
 uagl2h                   2   Online, rgmanager

 Service Name             Owner (Last)             State         
 ------- ----             ----- ------             -----         
 vm:VMG                   (uagl1h)                 disabled      
[root@uagl1 ~]#


4.Start the service (vm:VMG) on alternative node.

[root@uagl1 ~]# clusvcadm -e vm:VMG -m uagl2h
Member uagl2h trying to enable vm:VMG...Success
vm:VMG is now running on uagl2h
[root@uagl1 ~]# ssh uagl2h
Last login: Thu Oct 24 06:55:08 2013 from uagl1
[root@uagl2 ~]# clustat 
Cluster Status for uacl1 @ Fri Oct 25 04:24:28 2013
Member Status: Quorate
 Member Name             ID   Status
 ------ ----             ---- ------
 uagl1h                      1 Online, rgmanager
 uagl2h                      2 Online, Local, rgmanager

 Service Name             Owner (Last)             State         
 ------- ----             ----- ------             -----         
 vm:VMG                   uagl2h                   started       
[root@uagl2 ~]#


5.Check the virtual machine status in the alternative node.

[root@uagl2 ~]# virsh list
 Id    Name                           State
----------------------------------------------------
 3     VMG                            running
[root@uagl2 ~]#


We are able to migrate the virtual machine from one KVM node to another  node successfully with minimal downtime.If you use the live migration option, we can move the virtual machine from one node to another node without any downtime.(On the fly). Let’s see how we can do that with help of Redhat cluster. 

1. Login to any of the cluster node.

[root@uagl1 ~]# clustat 
Cluster Status for uacl1 @ Fri Oct 25 04:24:28 2013
Member Status: Quorate
 Member Name             ID   Status
 ------ ----             ---- ------
 uagl1h                      1 Online, Local, rgmanager
 uagl2h                      2 Online, rgmanager

 Service Name             Owner (Last)             State         
 ------- ----             ----- ------             -----         
 vm:VMG                   uagl2h                   started       
[root@uagl1 ~]#


2.Perform the Live-migration for service vm:VMG.

[root@uagl1 ~]# clusvcadm 
usage: clusvcadm [command]

Resource Group Control Commands:
  -v                     Display version and exit
  -d              Disable .  This stops a group
                         until an administrator enables it again,
                         the cluster loses and regains quorum, or
                         an administrator-defined event script
                         explicitly enables it again.
  -e              Enable 
  -e  -F          Enable  according to failover
                         domain rules (deprecated; always the
                         case when using central processing)
  -e  -m  Enable  on 
  -r  -m  Relocate  [to ]
                         Stops a group and starts it on another
                         cluster member.
  -M  -m  Migrate  to 
                         (e.g. for live migration of VMs)
  -q                     Quiet operation
  -R              Restart a group in place.
  -s              Stop .  This temporarily stops
                         a group.  After the next group or
                         or cluster member transition, the group
                         will be restarted (if possible).
  -Z              Freeze resource group.  This prevents
                         transitions and status checks, and is 
                         useful if an administrator needs to 
                         administer part of a service without 
                         stopping the whole service.
  -U              Unfreeze (thaw) resource group.  Restores
                         a group to normal operation.
Resource Group Locking (for cluster Shutdown / Debugging):
  -l                     Lock local resource group managers.
                         This prevents resource groups from
                         starting.
  -S                     Show lock state
  -u                     Unlock resource group managers.
                         This allows resource groups to start.
[root@uagl1 ~]#

[root@uagl1 ~]# clusvcadm -M vm:VMG -m uagl1h
Trying to migrate vm:VMG to uagl1h...Success
[root@uagl1 ~]# clustat 
Cluster Status for uacl1 @ Thu Oct 24 22:47:54 2013
Member Status: Quorate

 Member Name             ID   Status
 ------ ----             ---- ------
 uagl1h                      1 Online, Local, rgmanager
 uagl2h                      2 Online, rgmanager

 Service Name             Owner (Last)             State         
 ------- ----             ----- ------             -----         
 vm:VMG                   uagl1h                   started       
[root@uagl1 ~]#


3.You can see the virtual machine will not be halted or rebooted during this migration.

[root@uagl1 ~]# virsh list
 Id    Name                           State
----------------------------------------------------
 27    VMG                            running
[root@uagl1 ~]#


This migration is like vmware’s vmotion where we can move the virtual machine from one node to another node without any downtime.

Hope you enjoyed the KVM guest live migration. Please leave a comment if you have any doubt on this.

Thank you for visiting UnixArena.

VMTURBO-CLOUD-CAPACITY

Leave a Reply

Your email address will not be published. Required fields are marked *