openstack 实例只支持状态为active,stopped,error的实例进行救援,所以如果是其他状态的实例需要evacuate,则需要重置状态。


校验实例所在物理主机状态为down,并且实例状态为active,stopped,error才能执行evacuate并创建该实例的迁移任务


 


1,重置实例状态


实例i:c5dcb2c2-9ce4-463a-94b9-1c1615d37084


nova reset-state c5dcb2c2-9ce4-463a-94b9-1c1615d37084 --active


2,扩散实例到nova-28.os上


nova evacuate c5dcb2c2-9ce4-463a-94b9-1c1615d37084 nova-28.os


3,重启实例


nova stop c5dcb2c2-9ce4-463a-94b9-1c1615d37084 
nova start c5dcb2c2-9ce4-463a-94b9-1c1615d37084


通过openstack迁移


1. 查看实例信息


openstack server list  --long


| ID                                   | Name             | Status |  Networks                  | Host               |
+--------------------------------------+------------------+--------+----------------------------+--------------------+
| 5b9e1a99-d73f-46e3-acf4-c31a58c4e09a | test1            | ACTIVE |  lan-ceshi=10.200.40.237   |  nova05             |

2. 查看主机信息

openstack hypervisor list


+-----+---------------------+-----------------+--------------+-------+
|  ID | Hypervisor Hostname | Hypervisor Type | Host IP      | State |
+-----+---------------------+-----------------+--------------+-------+
|   3 | nova05              | QEMU            | 10.10.100.12 | down  |
|   6 | nova06              | QEMU            | 10.10.100.11 | up    |

3. 迁移

openstack server migrate --live-migration nova06.avlyun.org 5b9e1a99-d73f-46e3-acf4-c31a58c4e09a
...
openstack server list --long
| ID                                   | Name             | Status |  Networks                  | Host               |
+--------------------------------------+------------------+--------+----------------------------+--------------------+
| 5b9e1a99-d73f-46e3-acf4-c31a58c4e09a | test1            | ACTIVE |  lan-ceshi=10.200.40.237   |  nova06             |

注意: 通过openstack server migrate 迁移,两个主机的cpu参数需要一致。如果cpu不一样,会出现“ Unacceptable CPU info: CPU doesn't have compatibility ”。

解决:

# vim /usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py

注释掉cpu检测

# Compare CPU
"""
if not instance.vcpu_model or not instance.vcpu_model.model:
source_cpu_info = src_compute_info['cpu_info']
self._compare_cpu(None, source_cpu_info, instance)
else:
self._compare_cpu(instance.vcpu_model, None, instance)
"""