Live migration

One of the key tenets of cloud is being abstracted away from hardware. However, hardware does require maintenance from time to time, or a host will need a software upgrade. Whatever the reason, a host may need to be taken offline for maintenance, ideally with little to no downtime for the instances running on the host. To accommodate this, Nova provides two methods for live migrating instances: block migration, when shared storage is not available in the environment, and the live migration flag, when instances are booted from the shared storage (where every compute host can see the same storage used by each instance for its boot volume).

Getting ready

To live migrate an instance, you will need the following information:

  • The openstack command-line client
  • The openrc file containing appropriate administrator credentials
  • The name of the instance
  • The name of the destination hypervisor

Tip

If your environment is configured so that instances boot from the shared storage, such as RBD provided by Ceph, then live migrations are almost instantaneous (depending on how busy the instance is). A feature called block migration is much slower. Block migration is used in environments where shared storage is not used for instances.

Migrations can only be performed by a user with admin role privileges.

How to do it…

  1. First, we list the available hypervisors. We are noting where we can migrate our running instances to:
    openstack hypervisor list
    

    This will bring back an output like the following:

    How to do it…
  2. Next, view the instance properties to identify the source host:
    openstack server show cookbook.test
        -c name
        -c OS-EXT-SRV-ATTR:hypervisor_hostname
    

    This will bring back the fields (also known as column names, as denoted by the -c flag) that we are interested in. Note, in this example, the instance called cookbook.test is running from the hypervisor called compute-01.cook.book:

    How to do it…
  3. To live migrate the instance where no shared storage is available issue the following:
    openstack server migrate --block-migration cookbook.test
    

    Tip

    We do not specify a target compute host using the --block-migration method, instead, we let the Nova Scheduler decide on the next available hypervisor.

    This command shows no output when successful.

    To live migrate the instance, with shared storage such as Ceph, issue the following:

    openstack server migrate cookbook.test --live compute-02.cook.book
    

    Tip

    We specify the target hypervisor with the --live flag.

    This command shows no output when successful.

  4. Check the status of migration:
    openstack server show
        -c name
        -c OS-EXT-STS:task_state cookbook.test
    

    As block migrations generally take longer, you may see the state as resize_migrating, indicating that the task of migrating is still in process:

    How to do it…
  5. Verify the migration with the following command, ensuring that the instance is now running from a different hypervisor:
    openstack server show cookbook.test
        -c name
        -c OS-EXT-SRV-ATTR:hypervisor_hostname
    

    This will bring back an output like the following:

    How to do it…

Tip

Migrations of any kind are generally best performed when the instance is not under heavy utilization.

How it works…

Live migrations are an essential feature that enables OpenStack operators and administrators to perform maintenance of the underlying cloud infrastructure without affecting the consumers of said cloud. Additionally, the OpenStack administrator can use telemetry data from resource monitoring services (such as Ceilometer) and make live migration decisions to balance workloads across the OpenStack Cloud.

Live migration in OpenStack is handled by the libvirt drivers. Specifically, when you issue the openstack server migrate command, OpenStack Compute creates a connection from libvirtd on one compute host to the same process on the remote host. Once this connection is established, depending on the parameters you specified, the memory state of the instance is synchronized and the control is transferred. In the preceding example, we first specified the additional --block-migrate parameter, which handles the movement of the instance's disk files in the absence of shared storage, and then we showed how the --live flag can be used when instances are booted from shared storage.

Tip

Remember: Migrations can only be performed by users with the admin role.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.176.0