Migrating a Single Instance

Migration enables you to move a VM instance from one Compute host to another. Migration is useful for performing maintenance or redistributing workloads when there are too many VMs running on one host.

You can perform the following types of migration:

  • Non-live Migration—Shutting down an instance, moving it to another physical location, and restarting it. The instance recognizes this as a reboot and a service disruption.
  • Live Migration—Moving a running VM including memory, storage, and network connectivity to a different physical location without powering off or disconnecting the client.

See Migrating Volumes for information on data migration.

Migrations are not visible to non-admin users, but some operations cannot be peformed during a migration, such as attaching, detaching, or deleting a volume.

If the volume has snapshots, the specified host destination cannot accept the volume. If the user is not an administrator, the migration fails.

When you want to move an instance from one compute host to another, use the nova migrate command. The scheduler chooses the destination compute host based on its settings. This process does not assume that the instance has shared storage available on the target host. If you are using SSH tunneling, you must ensure that each node is configured with SSH key authentication so that the Compute service can use SSH to move disks to other nodes.

To migrate an instance:

  1. List the VMs to migrate.

    $ openstack host list
  2. View the host by VM_ID.

    $ openstack host show <VM_ID>
  3. Migrate the VM.

    $ nova migrate <VM_ID>

To migrate an instance and watch the status:


    # Provide usage
    usage() {
    echo "Usage: $0 <VM_ID>"
    exit 1

    [[ $# -eq 0 ]] && usage

    # Migrate the VM to an alternate hypervisor
    echo -n "Migrating instance to alternate host"
    nova migrate $<VM_ID>
    VM_OUTPUT=`nova show $<VM_ID>`
    VM_STATUS=`echo "$VM_OUTPUT" | grep status | awk '{print $4}'`
    while [[ "$VM_STATUS" != "VERIFY_RESIZE" ]]; do
    echo -n "."
    sleep 2
    VM_OUTPUT=`nova show $<VM_ID>`
    VM_STATUS=`echo "$<VM_OUTPUT>" | grep status | awk '{print $4}'`
    nova resize-confirm $<VM_ID>
    echo " instance migrated and resized."

    # Show the details for the VM
    echo "Updated instance details:"
    nova show $VM_ID

    # Pause to allow users to examine VM details
    read -p "Pausing, press <enter> to exit."

If you see the following error:

ERROR (Forbidden): Policy doesn't allow compute_extension:admin_actions:migrate to be performed. (HTTP 403)

You are running the command with non-administrator credentials.

If you see an error similar to this message, SSH tunneling was not set up between the compute nodes:

ProcessExecutionError: Unexpected error while running command.
Stderr: u Host key verification failed.\r\n

The instance is booted from a new host, but preserves its configuration including its ID, name, any metadata, IP address, and other properties.