kvm快照备份和恢复
查看磁盘格式:
ehs-rac-01]# cd /var/lib/libvirt/images/
images]# qemu-img info ehs-rac-01.qcow2
image: ehs-rac-01.qcow2
fileformat: qcow2
virtualsize: 30G (32212254720 bytes)
disksize: 34G
cluster_size: 65536
Snapshotlist:
IDTAG VM SIZE DATE VM CLOCK
1ehs-rac-01-bak 1.6G 2019-09-09 16:00:13 00:16:16.672
2ehs-rac-01-bak02 1.9G 2019-09-09 16:04:40 00:20:27.294
Formatspecific information:
compat: 1.1
lazyrefcounts: true
因为kvm虚拟机默认使用raw格式的镜像格式,性能最好,速度最快,它的缺点就是不支持一些新的功能,如支持镜像,zlib磁盘压缩,AES加密等。要使用镜像功能,磁盘格式必须为qcow2。如果格式为raw,那么需要来转换。可以看到我们的镜像格是qcow2,故无需改变镜像格式。
转换磁盘格式
[root@ehs-as-04 images]# qemu-imgconvert-fraw-Oqcow2ehs-rac-01.imgehs-rac-01.qcow2
-f 源镜像的格式
-O 目标镜像的格式
对虚拟机进行快照管理
创建快照
[ ]
[ ]
查看快照版本
[root@ehs-as-04 images]# virshsnapshot-listehs-rac-01
名称 生成时间 状态
------------------------------------------------------------
ehs-rac-01-bak 2019-09-09 16:00:13 +0800 running
ehs-rac-01-bak02 2019-09-09 16:04:39 +0800 running
查看当前虚拟机的快照版本
[root@ehs-as-04 images]# virsh snapshot-current ehs-rac-01
<domainsnapshot>
<name>ehs-rac-01-bak02</name>
<state>running</state>
<parent>
<name>ehs-rac-01-bak</name>
</parent>
<creationTime>1568016279</creationTime>
<memorysnapshot='internal'/>
<disks>
<diskname='hda'snapshot='internal'/>
<diskname='hdb'snapshot='no'/>
</disks>
...
查看当前的镜像文件:
[root@ehs-as-04 images]# qemu-imginfoehs-rac-01.qcow2
image: ehs-rac-01.qcow2
fileformat: qcow2
virtualsize: 30G (32212254720 bytes)
disksize: 34G
cluster_size: 65536
Snapshotlist:
IDTAGVMSIZEDATEVMCLOCK
1 ehs-rac-01-bak 1.6G 2019-09-09 16:00:13 00:16:16.672
2 ehs-rac-01-bak02 1.9G 2019-09-09 16:04:40 00:20:27.294
Formatspecificinformation:
compat: 1.1
lazyrefcounts: true
快照配置文件在/var/lib/libvirt/qemu/snapshot/虚拟机名称下
[rootas-04 images]# ll /var/lib/libvirt/qemu/snapshot/ehs-rac-01/ -
总用量 16
-rw------- 1 root root 52509月 916:04 ehs-rac-01-bak02.xml
-rw------- 1 root root 51939月 916:04 ehs-rac-01-bak.xml
恢复虚拟机快照
注:恢复快照,必须关机,确认虚拟机处于关机状态。
images]# virsh destroy ehs-rac-01
ehs-rac-01 被删除
images]# virsh list --all
Id名称 状态
----------------------------------------------------
10ehs-jboss-02 running
14ehs-mq-02 running
15ehs-jboss-01 running
17ehs-mq-01 running
23ehs-rac-02 running
ehs-oracle-01 关闭
ehs-oracle-02 关闭
ehs-rac-01 关闭
确认需要恢复的快照版本或时间,这里恢复到 ehs-rac-01-bak02
[root@ehs-as-04 images]# virshsnapshot-listehs-rac-01
名称 生成时间 状态
------------------------------------------------------------
ehs-rac-01-bak 2019-09-09 16:00:13 +0800 running
ehs-rac-01-bak02 2019-09-09 16:04:39 +0800 running
执行恢复操作
[ ]
如果按时间恢复需要把 ehs-rac-01-bak02 修改为时间戳
[ ]
删除虚拟机快照
先ehs-rac-01镜像对应有哪些快照
[root@ehs-as-04 images]# qemu-imginfoehs-rac-01.qcow2
image: ehs-rac-01.qcow2
fileformat: qcow2
virtualsize: 30G (32212254720 bytes)
disksize: 34G
cluster_size: 65536
Snapshotlist:
IDTAGVMSIZEDATEVMCLOCK
1 ehs-rac-01-bak 1.6G 2019-09-09 16:00:13 00:16:16.672
2 ehs-rac-01-bak02 1.9G 2019-09-09 16:04:40 00:20:27.294
Formatspecificinformation:
compat: 1.1
lazyrefcounts: true
删除第一个快照
[rootas-04 images]# virsh snapshot-delete ehs-rac-01 ehs-rac-01-bak -
已删除域快照 ehs-rac-01-bak
查看确认
[root@ehs-as-04 images]# virshsnapshot-listehs-rac-01
名称 生成时间 状态
------------------------------------------------------------
ehs-rac-01-bak02 2019-09-09 16:04:39 +0800 running
已经被删除。
链接:https://www.cnblogs.com/opma/p/11606951.html
(版权归原作者所有,侵删)
阅读原文 最新评论
推荐文章
作者最新文章
你可能感兴趣的文章
Copyright Disclaimer: The copyright of contents (including texts, images, videos and audios) posted above belong to the User who shared or the third-party website which the User shared from. If you found your copyright have been infringed, please send a DMCA takedown notice to [email protected]. For more detail of the source, please click on the button "Read Original Post" below. For other communications, please send to [email protected].
版权声明:以上内容为用户推荐收藏至CareerEngine平台,其内容(含文字、图片、视频、音频等)及知识版权均属用户或用户转发自的第三方网站,如涉嫌侵权,请通知[email protected]进行信息删除。如需查看信息来源,请点击“查看原文”。如需洽谈其它事宜,请联系[email protected]。
版权声明:以上内容为用户推荐收藏至CareerEngine平台,其内容(含文字、图片、视频、音频等)及知识版权均属用户或用户转发自的第三方网站,如涉嫌侵权,请通知[email protected]进行信息删除。如需查看信息来源,请点击“查看原文”。如需洽谈其它事宜,请联系[email protected]。