Instance Live Migration in OpenStack using CLI

Dear friend, in this tutorial we will see Instance Live Migration in OpenStack using CLI. Instance Migration will be needed when we need to migrate our running instance from one host to another host without any network break.

For more details you can see OpenStack site. Click here

Suppose if our one compute node is failing to provide compute services due to memory issue, CPU issue or any hardware issue then we can move our instance to another host and we can repaired our compute node.

We will follow these steps to perform instance migration

  1. Find the Instance ID.
  2. Determine the host where instance is running.
  3. Select the compute node where you want to migrate the instance.
  4. Before migration check the compute node has enough resources.
  5. Instance live migration to another host.
  6. Verify instance live migration.

Find the Instance ID

We can find the instance, which we want to move to another host. “openstack server list” command can be use to display instance list with Instance ID, where installer is our instance name and ID is our instance ID.

[[email protected] (cbamrc.v2) ~]$ openstack server list
 +--------------------------------------+--------------------+--------+-------------------------------------------------------------------------------------------+------------+
 | ID                                   | Name               | Status | Networks                                                                                  | Image Name |
 +--------------------------------------+--------------------+--------+-------------------------------------------------------------------------------------------+------------+
 | 02e5778c-e081-4125-a1f9-040cacb81ca5 | installer          | ACTIVE | CBAM-External-net=10.11.182.45                                                            | installer  |
 +--------------------------------------+--------------------+--------+-------------------------------------------------------------------------------------------+------------+
 [[email protected] (cbamrc.v2) ~]$

Determine the host where instance is running.

Determine the host where is our instance is running. “openstack server show installer” command can be use to display host were instance is running.

[[email protected] (cbamrc.v2) ~]$ openstack server show installer
 +--------------------------------------+------------------------------------------------------------+
 | Field                                | Value                                                      |
 +--------------------------------------+------------------------------------------------------------+
 | OS-DCF:diskConfig                    | AUTO                                                       |
 | OS-EXT-AZ:availability_zone          | zone1                                                      |
 | OS-EXT-SRV-ATTR:host                 | overcloud-sriovperformancecompute-1.localdomain            |
 | OS-EXT-SRV-ATTR:hypervisor_hostname  | overcloud-sriovperformancecompute-1.localdomain            |
 | OS-EXT-SRV-ATTR:instance_name        | instance-0000007a                                          |
 | OS-EXT-STS:power_state               | Running                                                    |
 | OS-EXT-STS:task_state                | None                                                       |
 | OS-EXT-STS:vm_state                  | active                                                     |
 | OS-SRV-USG:launched_at               | 2019-02-28T07:27:45.000000                                 |
 | OS-SRV-USG:terminated_at             | None                                                       |
 | accessIPv4                           |                                                            |
 | accessIPv6                           |                                                            |
 | addresses                            | CBAM-External-net=10.11.182.45                             |
 | config_drive                         |                                                            |
 | created                              | 2019-02-28T07:27:12Z                                       |
 | flavor                               | CBAM-installer-Node (c16a7c06-7c40-450a-9725-a144cf214377) |
 | hostId                               | 0259399f106b5eae5d0b1bda44fbe327ee4cb5710d987ad2bd91cb01   |
 | id                                   | 02e5778c-e081-4125-a1f9-040cacb81ca5                       |
 | image                                | installer (a79011d4-f04d-4dad-a91c-c46c54073446)           |
 | key_name                             | keypair-installer                                          |
 | name                                 | installer                                                  |
 | os-extended-volumes:volumes_attached | []                                                         |
 | progress                             | 0                                                          |
 | project_id                           | 67eff8b0b01f4d0abeb129df3debcd39                           |
 | properties                           |                                                            |
 | security_groups                      | [{u'name': u'cbam-installer-sec-group'}]                   |
 | status                               | ACTIVE                                                     |
 | updated                              | 2019-02-28T07:27:45Z                                       |
 | user_id                              | 185ad06f82b445419dcf4cd137144ab3                           |
 +--------------------------------------+------------------------------------------------------------+
 [[email protected] (cbamrc.v2) ~]$

Select the compute node where you want to migrate the instance.

Select the compute node where you want to migrate the instance. In this example, we will migrate the instance to overcloud-sriovperformancecompute-0.localdomain. dsemihidden

[[email protected] (cbamrc.v2) ~]$ openstack compute service list

Before migration check the compute node has enough resources.

We need to be check our compute node has enough resources are available or not? We can check resource status with this command “openstack host show overcloud-sriovperformancecompute-0.localdomain”.

[[email protected] (cbamrc.v2) ~]$ openstack host show overcloud-sriovperformancecompute-0.localdomain
 +-------------------------------------------------+------------+-----+-----------+---------+
 | Host                                            | Project    | CPU | Memory MB | Disk GB |
 +-------------------------------------------------+------------+-----+-----------+---------+
 | overcloud-sriovperformancecompute-0.localdomain | (total)    |  56 |    195222 |  210028 |
 | overcloud-sriovperformancecompute-0.localdomain | (used_now) |   0 |      2048 |       0 |
 | overcloud-sriovperformancecompute-0.localdomain | (used_max) |   0 |         0 |       0 |
 +-------------------------------------------------+------------+-----+-----------+---------+
 [[email protected] (cbamrc.v2) ~]$

Instance live migration to another host.

Now we can use this command “nova live-migration installer overcloud-sriovperformancecompute-0.localdomain” to migrate instance on compute node 0.

[[email protected] (cbamrc.v2) ~]$ nova live-migration installer overcloud-sriovperformancecompute-0.localdomain

Verify instance live migration.

After successfully performed instance migration command, we can check our instance is migrated successfully or not?

[[email protected] (cbamrc.v2) ~]$ openstack server show installer
 +--------------------------------------+------------------------------------------------------------+
 | Field                                | Value                                                      |
 +--------------------------------------+------------------------------------------------------------+
 | OS-DCF:diskConfig                    | AUTO                                                       |
 | OS-EXT-AZ:availability_zone          | zone1                                                      |
 | OS-EXT-SRV-ATTR:host                 | overcloud-sriovperformancecompute-0.localdomain            |
 | OS-EXT-SRV-ATTR:hypervisor_hostname  | overcloud-sriovperformancecompute-0.localdomain            |
 | OS-EXT-SRV-ATTR:instance_name        | instance-0000007a                                          |
 | OS-EXT-STS:power_state               | Running                                                    |
 | OS-EXT-STS:task_state                | None                                                       |
 | OS-EXT-STS:vm_state                  | active                                                     |
 | OS-SRV-USG:launched_at               | 2019-02-28T07:27:45.000000                                 |
 | OS-SRV-USG:terminated_at             | None                                                       |
 | accessIPv4                           |                                                            |
 | accessIPv6                           |                                                            |
 | addresses                            | CBAM-External-net=10.11.182.45                             |
 | config_drive                         |                                                            |
 | created                              | 2019-02-28T07:27:12Z                                       |
 | flavor                               | CBAM-installer-Node (c16a7c06-7c40-450a-9725-a144cf214377) |
 | hostId                               | 729810231b72766db0600b8578f11ca6f86f5a9f4591052a8ad9165f   |
 | id                                   | 02e5778c-e081-4125-a1f9-040cacb81ca5                       |
 | image                                | installer (a79011d4-f04d-4dad-a91c-c46c54073446)           |
 | key_name                             | keypair-installer                                          |
 | name                                 | installer                                                  |
 | os-extended-volumes:volumes_attached | []                                                         |
 | progress                             | 0                                                          |
 | project_id                           | 67eff8b0b01f4d0abeb129df3debcd39                           |
 | properties                           |                                                            |
 | security_groups                      | [{u'name': u'cbam-installer-sec-group'}]                   |
 | status                               | ACTIVE                                                     |
 | updated                              | 2019-03-07T06:07:42Z                                       |
 | user_id                              | 185ad06f82b445419dcf4cd137144ab3                           |
 +--------------------------------------+------------------------------------------------------------+
 [[email protected] (cbamrc.v2) ~]$

You can see in above output, our instance has been successfully migrated on compute node 1.

Leave a Reply

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