用xml文件找回虚拟机

计算节点损坏找回虚拟机

计算节点损坏,前提是虚拟机的数据没有删除(共享存储),如果计算节点没在 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
  1. 利用 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>
   
  1. 把修改好的 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   ## 注意文件权限和名称
  1. 登录数据库
 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
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,338评论 19 139
  • feisky云计算、虚拟化与Linux技术笔记posts - 1014, comments - 298, trac...
    不排版阅读 4,157评论 0 5
  • 石涛(1642年-1708年),清初画家,原姓朱,名若极,广西桂林人,祖籍安徽凤阳,小字阿长,别号很多,如大涤子、...
    文藝聯盟阅读 303评论 2 1
  • 董姑娘在吹灭十六岁生日蜡烛那一刻,清楚地认识到了一件事,并且她迅速地在当晚的床头会上与我分享了它。 她小心翼翼又惊...
    江汀州阅读 667评论 0 2

友情链接更多精彩内容