eric
作者eric·2015-05-15 17:40
系统运维工程师·某金融单位

openstack 快照分析 [

字数 2334阅读 2731评论 0赞 0

问题导读

1、什么是snapshot?

2、OpenStack如何进行snapshot?

3、OpenStack快照涉及哪些技术?

1.  snapshot 概述

对openstack而言,虚拟机的快照即是镜像,快照做完后以镜像形式存于glance。虽然openstack的快照是基于libvirt(qemu-kvm),但是二者在实现上有很大区别:

  • libvirt 主流快照实现: 采用virDomainSnapshotCreateXML()函数(CLI为virsh snapshot-create)。 新建的快照与虚拟机有关联:若为内置快照,快照信息和虚拟机存在同一个qcow2镜像中;若为外置快照,新建一个qcow2文件,原虚拟机的disk将变为一个read only的模板镜像,新qcow2镜像仅记录与2.模板镜像的差异数据。这种快照包含快照链信息,可保留disk和ram信息,可回滚至快照点。
  • openstack快照实现:openstack并未采用virDomainSnapshotCreateXML()来实现快照,而是单纯的对虚拟机镜像做转换和拷贝,生成一个与虚拟机无关联的镜像,最后上传至glance中。这种快照不包含快照链信息,只保留disk信息,无法回滚至快照点,只能采用该快照镜像创建一个新的虚拟机。

2. cold snapshot and live snapshot

cold snapshot:  创建snapshot时,需暂停虚拟机。

live snapshot:   创建snapshot时,无需暂停虚拟机。

3. cold snapshot 流程:

  1. Save the state and stop a running guest, then detach pci devices
  2.       $ virsh   managedsave   vm

复制代码

4. live snapshot 流程

  1. Abort any failed/finished block operations:
  2.      $ virsh blockjob vm vda --abort

  3. Undefine a running domain. (Note: Undefining a running domain does not _kill_ the domain, it just converts it from persistent to transient.)
  4.      $ virsh undefine vm

  5. create a destination image with the original backing file and matching size of the instance root disk.
  6.      $ qemu-img create -f qcow2 vm_copy --backing_file=backing_file --size=root_disk_size

  7. Invoke 'virsh blockcopy' (This will take time, depending on the size of disk image vm1):
  8.      $ virsh blockcopy --domain vm vda vm_copy --wait --verbose

  9. Abort any failed/finished block operations:
  10.     $ virsh blockjob vm vda --abort

  11. Define the guest again (to make it persistent):
  12.     $ virsh define vm

  13. From the obtained new copy, convert the QCOW2 with a backing file to a qcow2 image with no backing file, then upload to glance:
  14.     $ qemu-img convert -f qcow2 -O raw vm_copy vm_convert

复制代码

5. virsh snapshot-create-as/snapshot-create 快照简析 

    默认为内置快照,支持快照链,支持快照回滚,支持内存信息。

    快照过程中,虚拟机短暂卡顿。

    不知 openstack 为什么不通过该方法实现主流快照 ?!

6. conclusion

支持功能

  • 虚拟机快照(快照存放于glance)
  • 卷快照(LVM快照存放于本地)

限制与缺点

  • 没有快照链信息,不支持revert恢复虚拟机到某一个快照点
  • 只对系统盘进行快照,不支持内存快照,不支持同时对虚拟机和磁盘做快照
  • 需要用户进行一致性操作
  • 不支持含元数据导出,不支持含元数据导入
  • 只支持虚拟机全量数据快照(与快照的实现方式有关,因为是通过image进行保存的),过程较长(需要先通过存储快照,然后抽取并上传至glance),快照以Image方式保存,而非以cinder卷方式保存,无法充分利用存储本身能力加快快照的创建和使用

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

0

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广