Learn how to – How To Migrate OpenStack Instance from one Compute Host to Another.
It is possible to move an instance from one compute host to another in OpenStack. This is a common task when compute node has issues or maintenance has to be done on it. The openstack server migrate command is used to migrate an openstack instance from one compute host to another.
The Nova scheduler will automatically choose the destination compute host based on its settings. The migration process does not assume instance has shared storage available on the target host. For those using SSH tunneling, ensure that each node is configured with SSH key authentication so that the Compute service can use SSH to move disks to other nodes.
You can do a Live migration or Non-live migration. In Non-live migration, the instance is shut down, then moved to another hypervisor and restarted. The instance recognizes that it was rebooted, and the application running on the instance is disrupted.
With Live migration, the instance keeps running throughout the migration. This can be classified further by the way they treat instance storage:
- Shared storage-based live migration. The instance has ephemeral disks
that are located on storage shared between the source and destination
hosts. - Block live migration, or simply block migration. The instance has
ephemeral disks that are not shared between the source and destination
hosts. Block migration is incompatible with read-only devices such as
CD-ROMs and Configuration Drive (config_drive). - Volume-backed live migration. Instances use volumes rather than
ephemeral disks.
Step 1: Identify VM to Migrate
Identify the VM that you want to migrate. To list the VMs running on OpenStack, run:
$ openstack server list
+--------------------------------------+-------------+--------+----------------------+----------+----------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+-------------+--------+----------------------+----------+----------+
| 97cb5110-4135-4b59-8049-d19a29f64184 | dbvm01 | ACTIVE | public=172.20.150.70 | rhel-7.6 | m1.small |
| 8ba74eb3-469e-4535-8f30-ed75df303680 | webvm01 | ACTIVE | public=172.20.150.71 | rhel-7.6 | m1.small |
+--------------------------------------+-------------+--------+----------------------+----------+----------+
List hypervisors available:
$ openstack hypervisor list
+----+----------------------------------+-----------------+---------------+-------+
| ID | Hypervisor Hostname | Hypervisor Type | Host IP | State |
+----+----------------------------------+-----------------+---------------+-------+
| 1 | compute-01.osp.example.com | QEMU | 172.20.150.10 | up |
| 4 | compute-02.osp.example.com | QEMU | 172.20.150.11 | up |
+----+----------------------------------+-----------------+---------------+-------+
Get hypervisor service name:
$ openstack hypervisor show compute-01.osp.example.com
Use the openstack server migrate command to migrate an instance.
$ openstack server migrate <options> <server>
See available command options by running:
$ openstack server migrate --help
usage: openstack server migrate [-h] [--live <hostname>]
[--shared-migration | --block-migration]
[--disk-overcommit | --no-disk-overcommit]
[--wait]
<server>
Migrate server to different host
positional arguments:
<server> Server (name or ID)
optional arguments:
-h, --help show this help message and exit
--live <hostname> Target hostname
--shared-migration Perform a shared live migration (default)
--block-migration Perform a block live migration
--disk-overcommit Allow disk over-commit on the destination host
--no-disk-overcommit Do not over-commit disk on the destination host
(default)
--wait Wait for migrate to complete
Migration example:
$ openstack server migrate dbvm01
To migrate instance and ephemeral block disk:
openstack server migrate --block-migration --live compute-02.localdomain dbvm01
Where:
- compute-02.localdomain is the Target host hostname
- dbvm01 is the name of the instance to be migrated.
Check the instance migration status.
$ openstack server show dbvm01
+-------------------------------------+----------------------------------------------------------+
| Field | Value |
+-------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-SRV-ATTR:host | compute-01.localdomain |
| OS-EXT-SRV-ATTR:hypervisor_hostname | compute-01.osp.example.com |
| OS-EXT-SRV-ATTR:instance_name | instance-000000cf |
| OS-EXT-STS:power_state | Running |
| OS-EXT-STS:task_state | None |
| OS-EXT-STS:vm_state | resized |
| OS-SRV-USG:launched_at | 2019-09-18T08:59:09.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | public=172.20.150.70 |
| config_drive | |
| created | 2019-09-18T06:30:41Z |
| flavor | m1.medium (2) |
| hostId | 0535fdb75a2a49238da76c9b812629b3fc5522251ab791ef03287be9 |
| id | 3a82cf1f-93d0-47c6-931f-9d14472d9e45 |
| image | rhel-7.6 (3dcc3ae0-41ba-4371-afb2-c07c5c1725fb) |
| key_name | None |
| name | dbvm01 |
| progress | 0 |
| project_id | f278b83dd81848399a66d704aeb507b4 |
| properties | |
| security_groups | name='default' |
| status | VERIFY_RESIZE |
| updated | 2019-09-18T08:59:10Z |
| user_id | 9d6cd9e9847640ffbb2570a39d98aa55 |
| volumes_attached | |
+-------------------------------------+----------------------------------------------------------+
If the status is VERIFY_RESIZE. Manually confirm resize.
$ openstack server resize --confirm dbvm01
Status should be set to ACTIVE.
| status | ACTIVE |
More articles on OpenStack:
How To Install OpenStack on CentOS 7 with Packstack
How To Resize OpenStack Instance / Virtual Machine
Best books for Learning OpenStack Cloud Platform 2019
How To Install and Configure OpenStack Client on Linux
How To Configure OpenStack Instances / VMs to Autostart after Nova compute reboot
How To Create OpenStack Cinder Volumes and Attach to a VM Instance/Server on CLI
Leave a Reply
You must be logged in to post a comment.