Jaime Frutos Morales's blog

22/02/2010

How to make a live migration of a KVM virtual machine using virsh and SSH

Filed under: Linux, SysAdmin, Virtualization — acidborg @ 14:32

Description: A KVM virtual machine (guest) can be easily migrated from one host to another using virsh and SSH. The goal is to migrate guests without stopping them and with almost no downtime. This is very useful to balance the load among the hosts and to manage maintenance tasks.

Requirements:

  • The guest image must be located on a shared storage and it must be accessible using iSCSI, NFS, GFS2 or Fibre Channel.
  • The shared storage must be mounted on the same path on both hosts.
  • Both guests must run the same version of KVM.
  • Both guests must have the same network configuration and bridging configuration (their IPs must be different, of course).

Steps:

  • Verify that the guest is running on the source host: virsh list
    Id Name State
    -----------------------------
    1 test_guest running
  • Migrate the guest: virsh migrate --live test_guest qemu+ssh://destination_server/system
  • If you haven’t shared a pair of SSH keys between the hosts (highly recommended), enter the password.
  • Wait until the migration is completed (the guest will continue running until the end of the process).
  • Verify that the guest is running on the destination host: virsh list
    Id Name State
    -----------------------------
    1 test_guest running
About these ads

1 Comment

  1. Very simple and neat! Thank you!

    Comment by Cheng Luwei — 23/03/2010 @ 10:29


RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

The Shocking Blue Green Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 39 other followers

%d bloggers like this: