Openstack 通过修改数据库host间实例迁移

迁移:

旧主机:compute03

新主机:compute04

将实例从旧主机拷贝到新主机

scp -rp c0350e93-b767-4e86-84db-48c01a2adba8  root@192.168.20.254:/var/lib/nova/instances/

在新主机上修改实例文件权限

chown -R nova:nova c0350e93-b767-4e86-84db-48c01a2adba8/

数据库操作

查询当前 nova.instances 表中, 对应的物理主机信息

MariaDB [(none)]> select host, launched_on, node from nova.instances where uuid='c0350e93-b767-4e86-84db-48c01a2adba8';
+-----------+-------------+-----------+
| host      | launched_on | node      |
+-----------+-------------+-----------+
| compute03 | compute03   | compute03 |
+-----------+-------------+-----------+
1 row in set (0.00 sec)

直接修改成新主机

MariaDB [(none)]> update nova.instances set host='compute04-and-network', launched_on='compute04-and-network', node='compute04-and-network' where  uuid='c0350e93-b767-4e86-84db-48c01a2adba8';
Query OK, 1 row affected (0.04 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [(none)]> select host, launched_on, node from nova.instances where uuid='c0350e93-b767-4e86-84db-48c01a2adba8';
+-----------------------+-----------------------+-----------------------+
| host                  | launched_on           | node                  |
+-----------------------+-----------------------+-----------------------+
| compute04-and-network | compute04-and-network | compute04-and-network |
+-----------------------+-----------------------+-----------------------+
1 row in set (0.00 sec)

查询 neutron port 对应主机的信息

MariaDB [(none)]> select a.port_id, b.host from neutron.ipallocations a, neutron.ml2_port_bindings b where a.port_id = b.port_id and a.ip_address='172.16.2.8';
+--------------------------------------+-----------+
| port_id                              | host      |
+--------------------------------------+-----------+
| 676e3f97-1c4c-407a-b248-3af26e8548a6 | compute03 |
+--------------------------------------+-----------+
1 row in set (0.00 sec)

更新 port 信息

MariaDB [(none)]> update neutron.ml2_port_bindings set host='compute04-and-network' where port_id='676e3f97-1c4c-407a-b248-3af26e8548a6';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [(none)]> select a.port_id, b.host from neutron.ipallocations a, neutron.ml2_port_bindings b where a.port_id = b.port_id and a.ip_address='172.16.2.8';
+--------------------------------------+-----------------------+
| port_id                              | host                  |
+--------------------------------------+-----------------------+
| 676e3f97-1c4c-407a-b248-3af26e8548a6 | compute04-and-network |
+--------------------------------------+-----------------------+
1 row in set (0.01 sec)

检测主机信息

[root@controller ~]# nova show c0350e93-b767-4e86-84db-48c01a2adba8
+--------------------------------------+--------------------------------------------------------------------------+
| Property                             | Value                                                                    |
+--------------------------------------+--------------------------------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                                                   |
| OS-EXT-AZ:availability_zone          | nova                                                                     |
| OS-EXT-SRV-ATTR:host                 | compute04-and-network                                                    |
| OS-EXT-SRV-ATTR:hostname             | dev-docker-central-master-80-20                                          |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | compute04-and-network                                                    |
| OS-EXT-SRV-ATTR:instance_name        | instance-00000133                                                        |
| 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-y2wpxeyb                                                               |
| OS-EXT-SRV-ATTR:root_device_name     | /dev/vda                                                                 |
| OS-EXT-SRV-ATTR:user_data            | -                                                                        |
| OS-EXT-STS:power_state               | 0                                                                        |
| OS-EXT-STS:task_state                | -                                                                        |
| OS-EXT-STS:vm_state                  | stopped                                                                  |
| OS-SRV-USG:launched_at               | 2018-04-14T07:26:32.000000                                               |
| OS-SRV-USG:terminated_at             | -                                                                        |
| accessIPv4                           |                                                                          |
| accessIPv6                           |                                                                          |
| config_drive                         |                                                                          |
| created                              | 2018-04-14T07:25:47Z                                                     |
| description                          | dev-docker-central-master-80-20                                          |
| flavor                               | C8M32D150 (e0828ffe-703e-4a56-84f4-7e12d317325f)                         |
| hostId                               | d53439a60b9112c9613c4e482b54a50d52fa726d2159549f48d16826                 |
| host_status                          | UP                                                                       |
| id                                   | c0350e93-b767-4e86-84db-48c01a2adba8                                     |
| image                                | Docker-Central-Master-Es-Kafka-v2 (719650a6-ac09-432f-b585-d2d31f1b3cf8) |
| key_name                             | open                                                                     |
| locked                               | False                                                                    |
| metadata                             | {}                                                                       |
| name                                 | dev-docker-central-master-80-20                                          |
| os-extended-volumes:volumes_attached | []                                                                       |
| security_groups                      | default                                                                  |
| status                               | SHUTOFF                                                                  |
| tags                                 | []                                                                       |
| tenant_id                            | efa6a091ce914351a1b187c91a246e8b                                         |
| updated                              | 2018-08-07T01:46:15Z                                                     |
| user_id                              | 4e081a9e9edc483cb162814d2a09118c                                         |
| yamibuy-qc-private network           | 172.16.2.8, 10.30.80.20                                                  |
+--------------------------------------+--------------------------------------------------------------------------+

对主机重置状态

[root@controller ~]# nova reset-state c0350e93-b767-4e86-84db-48c01a2adba8
Reset state for server c0350e93-b767-4e86-84db-48c01a2adba8 succeeded; new state is error
[root@controller ~]# nova stop c0350e93-b767-4e86-84db-48c01a2adba8
Request to stop server c0350e93-b767-4e86-84db-48c01a2adba8 has been accepted.

 

转载于:https://my.oschina.net/devopsxin/blog/1923691

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值