标签:nbsp size 关机 管理 配置文件 修改 raw 必须 inf
查看磁盘格式:
[root@ehs-as-04 ehs-rac-01]# cd /var/lib/libvirt/images/ [root@ehs-as-04 images]# qemu-img info ehs-rac-01.qcow2 image: ehs-rac-01.qcow2 file format: qcow2 virtual size: 30G (32212254720 bytes) disk size: 34G cluster_size: 65536 Snapshot list: ID TAG VM SIZE DATE VM CLOCK 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 Format specific information: compat: 1.1 lazy refcounts: true
[root@ehs-as-04 images]# qemu-img convert -f raw -O qcow2 ehs-rac-01.img ehs-rac-01.qcow2 -f 源镜像的格式 -O 目标镜像的格式
[root@ehs-as-04 images]# virsh snapshot-create ehs-rac-01 ##也可以给快照起个别名 [root@ehs-as-04 images]# virsh snapshot-create-as ehs-rac-01 ehs-rac-01-bak
查看快照版本
[root@ehs-as-04 images]# virsh snapshot-list ehs-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> <memory snapshot=‘internal‘/> <disks> <disk name=‘hda‘ snapshot=‘internal‘/> <disk name=‘hdb‘ snapshot=‘no‘/> </disks> ...
查看当前的镜像文件:
[root@ehs-as-04 images]# qemu-img info ehs-rac-01.qcow2 image: ehs-rac-01.qcow2 file format: qcow2 virtual size: 30G (32212254720 bytes) disk size: 34G cluster_size: 65536 Snapshot list: ID TAG VM SIZE DATE VM CLOCK 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 Format specific information: compat: 1.1 lazy refcounts: true
快照配置文件在/var/lib/libvirt/qemu/snapshot/虚拟机名称下
[root@ehs-as-04 images]# ll /var/lib/libvirt/qemu/snapshot/ehs-rac-01/ 总用量 16 -rw------- 1 root root 5250 9月 9 16:04 ehs-rac-01-bak02.xml -rw------- 1 root root 5193 9月 9 16:04 ehs-rac-01-bak.xml
[root@ehs-as-04 images]# virsh destroy ehs-rac-01 域 ehs-rac-01 被删除 [root@ehs-as-04 images]# virsh list --all Id 名称 状态 ---------------------------------------------------- 10 ehs-jboss-02 running 14 ehs-mq-02 running 15 ehs-jboss-01 running 17 ehs-mq-01 running 23 ehs-rac-02 running - ehs-oracle-01 关闭 - ehs-oracle-02 关闭 - ehs-rac-01 关闭
确认需要恢复的快照版本或时间,这里恢复到 ehs-rac-01-bak02
[root@ehs-as-04 images]# virsh snapshot-list ehs-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-revert ehs-rac-01 ehs-rac-01-bak02
如果按时间恢复需要把 ehs-rac-01-bak02 修改为时间戳
[root@ehs-as-04 images]# virsh snapshot-revert ehs-rac-01 1500373324
[root@ehs-as-04 images]# qemu-img info ehs-rac-01.qcow2 image: ehs-rac-01.qcow2 file format: qcow2 virtual size: 30G (32212254720 bytes) disk size: 34G cluster_size: 65536 Snapshot list: ID TAG VM SIZE DATE VM CLOCK 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 Format specific information: compat: 1.1 lazy refcounts: true
删除第一个快照
[root@ehs-as-04 images]# virsh snapshot-delete ehs-rac-01 ehs-rac-01-bak 已删除域快照 ehs-rac-01-bak
查看确认
[root@ehs-as-04 images]# virsh snapshot-list ehs-rac-01 名称 生成时间 状态 ------------------------------------------------------------ ehs-rac-01-bak02 2019-09-09 16:04:39 +0800 running
已经被删除。
标签:nbsp size 关机 管理 配置文件 修改 raw 必须 inf
原文地址:https://www.cnblogs.com/opma/p/11606951.html