openstack i版 损坏云主机系统修复


参考文章:http://blog.csdn.net/hbsong75/article/details/8966598


环境要求:

disk文件为文件存储类型的云主机。



1、找到或创建一台与损坏云主机OS版本一致的云主机

2、将损坏云主机A的磁盘文件disk拷贝一份至用于修复云主机B disk_bak

ls /var/lib/nova/instances/8a902cdf-2967-48c0-b928-df46544c78d5/disk_bak

-rw-r--r-- 1 root root 36662149120 6月  25 15:29 disk_bak

3、在修云主机B目录下创建xml文件

相关target 信息根据libvirt.xml作变更

cat attach.xml
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/nova/instances/8a902cdf-2967-48c0-b928-df46544c78d5/disk_bak'/>
      <target dev='vdc' bus='virtio'/>

   </disk>


4、加载磁盘

查看实例名称

Virsh list|grep 8a902cdf-2967-48c0-b928-df46544c78d5

通过名称挂载disk

virsh attach-device instance-00008ba9 attach.xml
成功附加设备


5、查看是否挂载成功

在宿主机上查看

virsh dumpxml instance-00008ba9

云主机内查看

fdisk -l

Disk /dev/vda: 21.4 GB, 21474836480 bytes
16 heads, 63 sectors/track, 41610 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1         407      205127+  83  Linux
/dev/vda2             408       41610    20766312   83  Linux

Disk /dev/vdb: 1073 MB, 1073741824 bytes
16 heads, 63 sectors/track, 2080 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Disk /dev/vdb doesn't contain a valid partition table

Disk /dev/vdc: 42.9 GB, 42949672960 bytes
16 heads, 63 sectors/track, 83220 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/vdc1   *           1         407      205127+  83  Linux
/dev/vdc2             408       83220    41737752   83  Linux


6、进行挂载修复工作


7、卸载

virsh detach-device instance-00008ba9 attach.xml      
成功分离设备


8、备份云主机A的disk盘


9、将disk_bak变成云主机A的disk,重启云主机A即可

你可能感兴趣的:(kvm,openstack,修复)