在OpenStack云平台上手动迁移云主机操作步骤

在OpenStack云平台上手动迁移云主机

代码语言:javascript
复制
[root@controller ~]# source /etc/keystone/admin-openrc.sh 
[root@controller ~]# nova list
+--------------------------------------+-----------+--------+------------+-------------+------------------------+
| ID                                   | Name      | Status | Task State | Power State | Networks               |
+--------------------------------------+-----------+--------+------------+-------------+------------------------+
| c2b5ed8f-0a7c-4bd4-adab-78b096cb0857 | master    | ACTIVE | -          | Running     | ext-net=192.168.200.6  |
| a372558d-884c-421f-9b32-2dce2e99118e | node      | ACTIVE | -          | Running     | ext-net=192.168.200.7  |
| 5136c8ff-76ea-466d-b0c1-ae4be6f693e2 | rabbitmq1 | ACTIVE | -          | Running     | ext-net=192.168.200.21 |
| 6901f6ae-31de-4dbf-b37b-673d9526e135 | rabbitmq2 | ACTIVE | -          | Running     | ext-net=192.168.200.5  |
| 0fe821f7-7184-4378-90d2-0e62a0f03600 | rabbitmq3 | ACTIVE | -          | Running     | ext-net=192.168.200.3  |
+--------------------------------------+-----------+--------+------------+-------------+------------------------+
[root@controller ~]# nova show rabbitmq1
+--------------------------------------+----------------------------------------------------------+
| Property                             | Value                                                    |
+--------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig                    | AUTO                                                     |
| OS-EXT-AZ:availability_zone          | nova                                                     |
| OS-EXT-SRV-ATTR:host                 | controller                                               |
| OS-EXT-SRV-ATTR:hostname             | rabbitmq1                                                |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | controller                                               |
| OS-EXT-SRV-ATTR:instance_name        | instance-00000019                                        |
| OS-EXT-SRV-ATTR:kernel_id            |                                                          |
| OS-EXT-SRV-ATTR:launch_index         | 0                                                        |
| OS-EXT-SRV-ATTR:ramdisk_id           |                                                          |
| OS-EXT-SRV-ATTR:reservation_id       | r-9q8w190y                                               |
| OS-EXT-SRV-ATTR:root_device_name     | /dev/vda                                                 |
| OS-EXT-SRV-ATTR:user_data            | -                                                        |
| OS-EXT-STS:power_state               | 1                                                        |
| OS-EXT-STS:task_state                | -                                                        |
| OS-EXT-STS:vm_state                  | active                                                   |
| OS-SRV-USG:launched_at               | 2020-11-19T00:47:28.000000                               |
| OS-SRV-USG:terminated_at             | -                                                        |
| accessIPv4                           |                                                          |
| accessIPv6                           |                                                          |
| config_drive                         |                                                          |
| created                              | 2020-11-19T00:47:19Z                                     |
| description                          | -                                                        |
| ext-net network                      | 192.168.200.21                                           |
| flavor:disk                          | 20                                                       |
| flavor:ephemeral                     | 0                                                        |
| flavor:extra_specs                   | {}                                                       |
| flavor:original_name                 | mysql                                                    |
| flavor:ram                           | 2048                                                     |
| flavor:swap                          | 0                                                        |
| flavor:vcpus                         | 1                                                        |
| hostId                               | c679b0b05edfbd4e0072f93d8408ff78bff3a4cbde7b02e93690c7b5 |
| host_status                          | UP                                                       |
| id                                   | 5136c8ff-76ea-466d-b0c1-ae4be6f693e2                     |
| image                                | centos7.5 (8b03410b-4f3d-49fa-9acf-c0a1aa20160c)         |
| key_name                             | -                                                        |
| locked                               | False                                                    |
| metadata                             | {}                                                       |
| name                                 | rabbitmq1                                                |
| os-extended-volumes:volumes_attached | []                                                       |
| progress                             | 0                                                        |
| security_groups                      | default                                                  |
| status                               | ACTIVE                                                   |
| tags                                 | []                                                       |
| tenant_id                            | 03a2483a6b364606b7e0bc3ccc6064b2                         |
| updated                              | 2020-11-19T00:47:28Z                                     |
| user_id                              | f54f627a05984048984fd117c894925e                         |
+--------------------------------------+----------------------------------------------------------+
[root@controller ~]# nova stop rabbitmq1
Request to stop server rabbitmq1 has been accepted.
[root@controller ~]# cd /var/lib/nova/instances/
[root@controller instances]# ll
total 4
drwxr-xr-x. 2 nova nova  54 Nov 19 08:47 5136c8ff-76ea-466d-b0c1-ae4be6f693e2
drwxr-xr-x. 2 nova nova  54 Nov 19 08:53 6901f6ae-31de-4dbf-b37b-673d9526e135
drwxr-xr-x. 2 nova nova 102 Nov 18 14:15 _base
-rw-r--r--. 1 nova nova  33 Nov 19 08:22 compute_nodes
drwxr-xr-x. 2 nova nova 146 Nov 18 14:13 locks
[root@controller instances]# cd 5136c8ff-76ea-466d-b0c1-ae4be6f693e2/
[root@controller 5136c8ff-76ea-466d-b0c1-ae4be6f693e2]# ll
total 118992
-rw-------. 1 root root     52436 Nov 19 09:29 console.log
-rw-r--r--. 1 root root 121831424 Nov 19 09:29 disk
-rw-r--r--. 1 nova nova        79 Nov 19 08:47 disk.info
[root@controller 5136c8ff-76ea-466d-b0c1-ae4be6f693e2]# cd ..
[root@controller instances]# scp -r 5136c8ff-76ea-466d-b0c1-ae4be6f693e2 root@compute:/var/lib/nova/instances/
root@compute's password: 
disk.info                                                                            100%   79     7.2KB/s   00:00    
disk                                                                                 100%  116MB   6.5MB/s   00:18    
console.log                                                                          100%   51KB   3.8MB/s   00:00    
[root@controller instances]# rm -rf 5136c8ff-76ea-466d-b0c1-ae4be6f693e2/

【compute】

[root@compute ~]# cd /var/lib/nova/instances/
[root@compute instances]# ll
total 4
drwxr-xr-x. 2 nova nova 54 Nov 19 08:55 0fe821f7-7184-4378-90d2-0e62a0f03600
drwxr-xr-x. 2 root root 54 Nov 19 09:30 5136c8ff-76ea-466d-b0c1-ae4be6f693e2
drwxr-xr-x. 2 nova nova 54 Nov 14 17:02 a372558d-884c-421f-9b32-2dce2e99118e
drwxr-xr-x. 2 nova nova 54 Nov 13 11:55 _base
drwxr-xr-x. 2 nova nova 54 Nov 14 17:00 c2b5ed8f-0a7c-4bd4-adab-78b096cb0857
-rw-r--r--. 1 nova nova 30 Nov 19 09:00 compute_nodes
drwxr-xr-x. 2 nova nova 93 Nov 13 12:29 locks
[root@compute instances]# chown nova:nova 5136c8ff-76ea-466d-b0c1-ae4be6f693e2/

【controller】
[root@controller instances]# mysql -uroot -p000000
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 13553
Server version: 10.1.20-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| cinder |
| glance |
| heat |
| information_schema |
| keystone |
| mysql |
| neutron |
| nova |
| nova_api |
| nova_cell0 |
| performance_schema |
| zun |
+--------------------+
12 rows in set (0.01 sec)

MariaDB [(none)]> use nova
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [nova]> update instances set host='compute',node='compute' where uuid='5136c8ff-76ea-466d-b0c1-ae4be6f693e2';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [nova]> flush privileges;
Query OK, 0 rows affected (0.08 sec)

MariaDB [nova]> Ctrl-C -- exit!
Aborted

【compute】
MainPID=25265 Id=openstack-nova-compute.service ActiveState=active
[root@compute instances]# systemctl restart openstack-nova-compute.service
[root@compute instances]# nova start 5136c8ff-76ea-466d-b0c1-ae4be6f693e2
Request to start server 5136c8ff-76ea-466d-b0c1-ae4be6f693e2 has been accepted.
[root@compute instances]# nova list
+--------------------------------------+-----------+---------+-------------+-------------+------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+-----------+---------+-------------+-------------+------------------------+
| c2b5ed8f-0a7c-4bd4-adab-78b096cb0857 | master | ACTIVE | - | Running | ext-net=192.168.200.6 |
| a372558d-884c-421f-9b32-2dce2e99118e | node | ACTIVE | - | Running | ext-net=192.168.200.7 |
| 5136c8ff-76ea-466d-b0c1-ae4be6f693e2 | rabbitmq1 | SHUTOFF | powering-on | Shutdown | ext-net=192.168.200.21 |
| 6901f6ae-31de-4dbf-b37b-673d9526e135 | rabbitmq2 | ACTIVE | - | Running | ext-net=192.168.200.5 |
| 0fe821f7-7184-4378-90d2-0e62a0f03600 | rabbitmq3 | ACTIVE | - | Running | ext-net=192.168.200.3 |
+--------------------------------------+-----------+---------+-------------+-------------+------------------------+
[root@compute instances]# nova list
+--------------------------------------+-----------+--------+------------+-------------+------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+-----------+--------+------------+-------------+------------------------+
| c2b5ed8f-0a7c-4bd4-adab-78b096cb0857 | master | ACTIVE | - | Running | ext-net=192.168.200.6 |
| a372558d-884c-421f-9b32-2dce2e99118e | node | ACTIVE | - | Running | ext-net=192.168.200.7 |
| 5136c8ff-76ea-466d-b0c1-ae4be6f693e2 | rabbitmq1 | ACTIVE | - | Running | ext-net=192.168.200.21 |
| 6901f6ae-31de-4dbf-b37b-673d9526e135 | rabbitmq2 | ACTIVE | - | Running | ext-net=192.168.200.5 |
| 0fe821f7-7184-4378-90d2-0e62a0f03600 | rabbitmq3 | ACTIVE | - | Running | ext-net=192.168.200.3 |
+--------------------------------------+-----------+--------+------------+-------------+------------------------+

[root@compute instances]# nova show rabbitmq1
+--------------------------------------+----------------------------------------------------------+
| Property | Value |
+--------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig | AUTO |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-SRV-ATTR:host | compute |
| OS-EXT-SRV-ATTR:hostname | rabbitmq1 |
| OS-EXT-SRV-ATTR:hypervisor_hostname | compute |
| OS-EXT-SRV-ATTR:instance_name | instance-00000019 |
| OS-EXT-SRV-ATTR:kernel_id | |
| OS-EXT-SRV-ATTR:launch_index | 0 |
| OS-EXT-SRV-ATTR:ramdisk_id | |
| OS-EXT-SRV-ATTR:reservation_id | r-9q8w190y |
| OS-EXT-SRV-ATTR:root_device_name | /dev/vda |
| OS-EXT-SRV-ATTR:user_data | - |
| OS-EXT-STS:power_state | 1 |
| OS-EXT-STS:task_state | - |
| OS-EXT-STS:vm_state | active |
| OS-SRV-USG:launched_at | 2020-11-19T00:47:28.000000 |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| config_drive | |
| created | 2020-11-19T00:47:19Z |
| description | - |
| ext-net network | 192.168.200.21 |
| flavor:disk | 20 |
| flavor:ephemeral | 0 |
| flavor:extra_specs | {} |
| flavor:original_name | mysql |
| flavor:ram | 2048 |
| flavor:swap | 0 |
| flavor:vcpus | 1 |
| hostId | 542871f997cea71ff625ae4999c7455f3d96b937926f092633d6e153 |
| host_status | UP |
| id | 5136c8ff-76ea-466d-b0c1-ae4be6f693e2 |
| image | centos7.5 (8b03410b-4f3d-49fa-9acf-c0a1aa20160c) |
| key_name | - |
| locked | False |
| metadata | {} |
| name | rabbitmq1 |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| security_groups | default |
| status | ACTIVE |
| tags | [] |
| tenant_id | 03a2483a6b364606b7e0bc3ccc6064b2 |
| updated | 2020-11-19T01:38:36Z |
| user_id | f54f627a05984048984fd117c894925e |
+--------------------------------------+----------------------------------------------------------+

在这里插入图片描述