The live migration feature is useful when you need to upgrade or installing patches to hypervisors/BIOS and you need the machines to keep running; for example, when one of HDD volumes RAID or one of bonded NICs is out of order. Also for regular periodic maintenance, you may need to migrate VM instances. When many VM instances are running on a specific physical machine, you can redistribute the high load. Sometimes when VM instances are scattered, you can move VM instances to a physical machine to arrange them more logically.
Prerequisites
OS:Ubuntu 10.04 or 12.04
Shared storage: NOVA-INST-DIR/instances/ (eg /var/lib/nova/instances) has to be mounted by shared storage. This guide uses NFS but other options, including the OpenStack Gluster Connector are available.
Instances: Instance can be migrated with ISCSI based volumes
Hypervisor: KVM with libvirt
![]() | Note |
|---|---|
This guide assumes the default value for instances_path in your nova.conf ("NOVA-INST-DIR/instances"). If you have changed the state_path or instances_path variables, please modify accordingly |
![]() | Note |
|---|---|
This feature for cloud administrators only, since the use of nova-manage is necessary. |
![]() | Note |
|---|---|
You must specify |
Example Nova Installation Environment
Prepare 3 servers at least; for example, HostA, HostB and HostC
HostA is the "Cloud Controller", and should be running: nova-api, nova-scheduler, nova-network, nova-volume, nova-objectstore, nova-scheduler.
Host B and Host C are the "compute nodes", running nova-compute.
Ensure that, NOVA-INST-DIR (set with state_path in nova.conf) is same on all hosts.
In this example, HostA will be the NFSv4 server which exports NOVA-INST-DIR/instances, and HostB and HostC mount it.
System configuration
Configure your DNS or
/etc/hostsand ensure it is consistent accross all hosts. Make sure that the three hosts can perform name resolution with each other. As a test, use the ping command to ping each host from one another.$ ping HostA $ ping HostB $ ping HostC
Follow the instructions at the Ubuntu NFS HowTo to setup an NFS server on HostA, and NFS Clients on HostB and HostC.
Our aim is to export NOVA-INST-DIR/instances from HostA, and have it readable and writable by the nova user on HostB and HostC.
Using your knowledge from the Ubuntu documentation, configure the NFS server at HostA by adding a line to
/etc/exports$ NOVA-INST-DIR/instances HostA/255.255.0.0(rw,sync,fsid=0,no_root_squash)
Change the subnet mask (
255.255.0.0) to the appropriate value to include the IP addresses of HostB and HostC. Then restart the NFS server.$ /etc/init.d/nfs-kernel-server restart $ /etc/init.d/idmapd restart
Set the 'execute/search' bit on your shared directory
On both compute nodes, make sure to enable the 'execute/search' bit to allow qemu to be able to use the images within the directories. On all hosts, execute the following command:
$ chmod o+x NOVA-INST-DIR/instances
Configure NFS at HostB and HostC by adding below to /etc/fstab
$ HostA:/NOVA-INST-DIR/instances /NOVA-INST-DIR/instances nfs4 defaults 0 0
Then ensure that the exported directory can be mounted.
$ mount -a -v
Check that "
" directory can be seen at HostANOVA-INST-DIR/instances/$ ls -ld NOVA-INST-DIR/instances/
drwxr-xr-x 2 nova nova 4096 2012-05-19 14:34 nova-install-dir/instances/Perform the same check at HostB and HostC - paying special attention to the permissions (nova should be able to write)
$ ls -ld NOVA-INST-DIR/instances/
drwxr-xr-x 2 nova nova 4096 2012-05-07 14:34 nova-install-dir/instances/$ df -k
Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 921514972 4180880 870523828 1% / none 16498340 1228 16497112 1% /dev none 16502856 0 16502856 0% /dev/shm none 16502856 368 16502488 1% /var/run none 16502856 0 16502856 0% /var/lock none 16502856 0 16502856 0% /lib/init/rw HostA: 921515008 101921792 772783104 12% /var/lib/nova/instances ( <--- this line is important.)
Update the libvirt configurations. Modify
/etc/libvirt/libvirtd.conf:before : #listen_tls = 0 after : listen_tls = 0 before : #listen_tcp = 1 after : listen_tcp = 1 add: auth_tcp = "none"Modify
/etc/init/libvirt-bin.confbefore : exec /usr/sbin/libvirtd -d after : exec /usr/sbin/libvirtd -d -lModify
/etc/default/libvirt-binbefore :libvirtd_opts=" -d" after :libvirtd_opts=" -d -l"Restart libvirt. After executing the command, ensure that libvirt is succesfully restarted.
$ stop libvirt-bin && start libvirt-bin $ ps -ef | grep libvirt
root 1145 1 0 Nov27 ? 00:00:03 /usr/sbin/libvirtd -d -lConfigure your firewall to allow libvirt to communicate between nodes.
Information about ports used with libvirt can be found at the libvirt documentation By default, libvirt listens on TCP port 16509 and an ephemeral TCP range from 49152 to 49261 is used for the KVM communications. As this guide has disabled libvirt auth, you should take good care that these ports are only open to hosts within your installation.
You can now configure options for live migration. In most cases, you do not need to configure any options. The following chart is for advanced usage only.
| Configuration option=Default value | (Type) Description |
| live_migration_bandwidth=0 | (IntOpt) Define live migration behavior |
| live_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER | (StrOpt) Define live migration behavior. |
| live_migration_retry_count=30 | (IntOpt) Number of 1 second retries needed in live_migration |
| live_migration_uri=qemu+tcp://%s/system | (StrOpt) Define protocol used by live_migration feature |

![[Note]](../common/images/admon/note.png)
