用xml文件找回虚拟机
2018-08-13 本文已影响0人
hamburger01
计算节点损坏找回虚拟机
计算节点损坏,前提是虚拟机的数据没有删除(共享存储),如果计算节点没在 hypervisor 中删除可尝试 evacuate 找回
如果在 hypervisor 中删除了,可用下面方法
1.用相同的租户,相同的启动方式,新建一个相同的虚拟机 # network flavor image 相同
nova boot --flavor 1C1G --security-group default --nic net-name=shanxi-net --nic net-name=ext-net-cn2 --block-device id=1e92e8e9-a246-43f3-9177-777f394fcb5a,source=image,dest=volume,bootindex=0,size=50,shutdown=remove --meta admin_pass=123 test-0709
2.登录 new_instace 计算节点获取xml文件
virsh dumpxml <domain> > new_instace.xml
- 利用 new_instace.xml 修改要恢复的虚拟机xml文件
1.全局替换把 new_instaceID 替换为要恢复的 instanceID
2.name='serial'>734c4580-f99a-4af7-93c2-9e6f4fdca308</entry> #相同计算节点serial相同
3 <source protocol='rbd' name='volumes/volume-a1a067dc-b8f9-4b2c-9dc1-0732d40fd9ca'> #修改 volume ID
<host name='10.129.176.62' port='6789'/>
<host name='10.129.176.63' port='6789'/>
<host name='10.129.176.64' port='6789'/>
<host name='10.129.176.72' port='6789'/>
<host name='10.129.176.81' port='6789'/>
</source>
<backingStore/>
<target dev='vda' bus='virtio'/>
<iotune>
<read_bytes_sec>94371840</read_bytes_sec>
<write_bytes_sec>94371840</write_bytes_sec>
<read_iops_sec>1000</read_iops_sec>
<write_iops_sec>1000</write_iops_sec>
</iotune>
<serial>a1a067dc-b8f9-4b2c-9dc1-0732d40fd9ca</serial>
4.<interface type='bridge'> # 修改 network 信息 nova interface-list instance_id 获取要修改的信息
<mac address='fa:16:3e:13:86:d2'/>
<source bridge='br-int'/>
<virtualport type='openvswitch'>
<parameters interfaceid='62de91d0-a404-49fa-9535-553235f97923'/>
</virtualport>
<target dev='tap62de91d0-a4'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
- 把修改好的 xml文件 放在new host上
/etc/libvirt/qemu/instance-eb72a860-f9e0-49a7-8744-9757f80e1ebc.xml
-rw------- 1 root root 5829 Jul 13 11:25 /etc/libvirt/qemu/instance-eb72a860-f9e0-49a7-8744-9757f80e1ebc.xml ## 注意文件权限和名称
- 登录数据库
update instances set host='new_host',node='new_host',launched_on='new_host' where uuid='old_instance_id';
launched_on 字段不修改也行
5.重启libvirt,启动虚拟机
systemctl restart libvirtd
nova start old_instance_id