Openstack

[Openstack] manual migration 수동 이전

plastic2113 2025. 1. 17. 06:44
728x90
반응형

# 운영중에 nova / openstack 명령어로 vm이 이전되지 않을 때 사용.

nova migrate [instance_id] or openstack server migrate [instance_id]  > ERROR... 

Migration : HOST_A > HOST_B

 

1. Move vm's disk HOST_A to HOST_B

- vm의 disk_base파일 등을 옮긴다.

root@HOST_A:~# scp [vm's_disk_PATH]/* nova@HOST_B:[vm's_disk_PATH]/
root@HOST_A:~# scp [vm's_base_PATH]/[_base_file] nova@HOST_B:[vm's_base_PATH]/

 

 

* 여기부터 중요 * important from here*

2. Update DB(mysql)

명령어로 vm의 위치를 변경한게 아니기 때문에 데이터베이스도 수정이 필요.

 

[nova]

MariaDB [nova] > select node, host from instances where uuid='[instance_id]';

MariaDB [nova] > select node, host from instances where uuid='[instance_id]';
+--------+--------+
| node   | host   |
+--------+--------+
| HOST_A | HOST_A |
+--------+--------+

 

MariaDB [nova] > update instances set node='[HOST_B]',host='[HOST_B]' where uuid='[instance_id]';

MariaDB [nova] > update instances set node='[HOST_B]',host='[HOST_B]' where uuid='[instance_id]';
Query OK, 1 row affected (0.019 sec)
Rows matched: 1  Changed: 1  Warnings: 0

 

MariaDB [nova] > select node, host from instances where uuid='[instance_id]';

MariaDB [nova] > select node, host from instances where uuid='[instance_id]';
+--------+--------+
| node   | host   |
+--------+--------+
| HOST_B | HOST_B |
+--------+--------+
반응형

[placement] or [nova_api]

* openstack버전에 따라 DB이름이 다름. (DB=placement or nova_api)

MariaDB [DB] > select id, name from resource_providers where name='[HOST_A]';

MariaDB [DB] > select id, name from resource_providers where name='[HOST_A]';
+------+--------+
| id   | name   |
+------+--------+
| 1111 | HOST_A |
+------+--------+

 

MariaDB [DB] > select id, name from resource_providers where name='[HOST_B]';

MariaDB [DB] > select id, name from resource_providers where name='[HOST_B]';
+------+--------+
| id   | name   |
+------+--------+
| 2222 | HOST_B |
+------+--------+

 

MariaDB [DB] > select * from allocations where consumer_id='[instance_id]';

MariaDB [DB] > select * from allocations where consumer_id='[instance_id]';
+----------------------+---------------+
| resource_provider_id | consumer_id   |
+----------------------+---------------+
|                 1111 | [instance_id] |
|                 1111 | [instance_id] |
|                 1111 | [instance_id] |
+----------------------+---------------+

 

 

 

MariaDB [DB] > update allocations set resource_provider_id='1111' where consumer_id='[instance_id]' and resource_provider_id='2222';

MariaDB [DB] > update allocations set resource_provider_id='1111' where consumer_id='[instance_id]' and resource_provider_id='2222';
Query OK, 3 rows affected (0.274 sec)
Rows matched: 3  Changed: 3  Warnings: 0

 

MariaDB [DB] > select * from allocations where consumer_id='[instance_id]';

MariaDB [DB] > select * from allocations where consumer_id='[instance_id]';
+----------------------+---------------+
| resource_provider_id | consumer_id   |
+----------------------+---------------+
|                 2222 | [instance_id] |
|                 2222 | [instance_id] |
|                 2222 | [instance_id] |
+----------------------+---------------+

Complete DB update.

728x90

3. Update Port

instance에 연결된 porthost를 변경해야함.

 

root@controller:~# openstack port show [port_id]

root@controller:~# openstack port show [port_id]
...
| binding_host_id   | HOST_A      |
...

 

root@controller:~# openstack port set --host HOST_B [port_id]

root@controller:~# openstack port show [port_id]

root@controller:~# openstack port show [port_id]
...
| binding_host_id   | HOST_B      |
...

 

 

728x90
반응형