Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Snapshot Management of KVM Virtual Machine

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the KVM virtual machine snapshot management example analysis, the article is very detailed, has a certain reference value, interested friends must read it!

Kvm virtual machine uses raw image format by default, which has the best performance and the fastest speed. Its disadvantage is that it does not support some new functions, such as supporting mirroring, zlib disk compression, AES encryption and so on.

To use the mirroring feature, the disk format must be qcow2.

View the disk format and convert:

[root@e3 images] # qemu-img info centos6.5.img image: kvm003.imgfile format: raw # you can see that the default kvm disk format is RAWvirtual size: 20g (21474836480 bytes) disk size: 1.8g

Shut down the virtual machine and convert the disk

[root@e3 images] # virsh list-- all Id name status-29 centos6.6 running-centos6.5 off -kvm001 off-kvm002 off-kvm003 off-template off

Conversion

[root@e3 images] # qemu-img convert-f raw-O qcow2 kvm003.img kvm003.qcow2 #-f specify source format-O specify conversion format [root@e3 images] # qemu-img info centos6.5.qcow2 [root@e3 images] # qemu-img info centos6.5.qcow2 image: centos6.5.qcow2file format: qcow2 # converted successfully virtual size: 20g (21474836480 bytes) disk size: 1.4Gcluster_size: 65536Format specific information: compat: 1.1 lazy refcounts: false

Modify virtual machine configuration fil

[root@e3 images] # virsh edit centos6.5 / usr/libexec/qemu-kvm # modify # modify

Take a snapshot of the virtual machine

[root@e3 images] # virsh snapshot-create centos6.5 generated domain snapshot 1421829141

View Snapshot

[root@e3 images] # virsh snapshot-list centos6.5 name generation time status-1421829141 2015-01-21 16:32:21 + 0800 shutoff

View the current virtual machine snapshot version

[root@e3 images] # virsh snapshot-current centos6.5 1421829141 # this shutoff 1421829141 centos6.5 34f5ab44-7800-4bc9-a9c1-5227460cf1fa 524288 524288

View virtual machine snapshot fil

[root@e3 images] # virsh snapshot-create centos6.5 generated domain snapshot 1421829551 [root@e3 images] # virsh snapshot-list centos6.5 name generation time status-1421829141 2015-01-21 16:32:21 + 0800 shutoff 1421829551 2015-01-21 16:39:11 + 0800 shutoff# because the virsh command is provided by libvirt-client, rpm-ql libvirt-client can see that the snapshot files are stored in / var/lib/libvirt [root@e3 images] # rpm-ql libvirt-client [root@e3 images] # cd / var/lib/libvirt/qemu/ [root@e3 qemu] # lscapabilities.monitor.sock centos6.6.monitor channel Dump save snapshot [root@e3 qemu] # ll total dosage 16srwxr-xr-x. 1 qemu qemu January 19 10:15 capabilities.monitor.socksrwxr-xr-x. 1 qemu qemu January 21 11:40 centos6.6.monitordrwxr-x---. 3 qemu qemu 4096 January 6 06:32 channeldrwxr-xr-x. 2 root root 4096 January 14 10:05 dumpdrwxr-xr-x. 2 qemu qemu 4096 January 14 10:05 savedrwxr-xr-x. 3 qemu qemu 4096 January 21 16:32 snapshot [root@e3 qemu] # ll total dosage 16srwxr-xr-x. 1 qemu qemu January 19 10:15 capabilities.monitor.socksrwxr-xr-x. 1 qemu qemu January 21 11:40 centos6.6.monitordrwxr-x---. 3 qemu qemu 4096 January 6 06:32 channeldrwxr-xr-x. 2 root root 4096 January 14 10:05 dumpdrwxr-xr-x. 2 qemu qemu 4096 January 14 10:05 savedrwxr-xr-x. 3 qemu qemu 4096 January 21 16:32 snapshot [root@e3 qemu] # cd snapshot/ [root@e3 snapshot] # ll total dosage 4drwxr-xr-x. 2 root root 4096 January 21 16:39 centos6.5 [root@e3 snapshot] # cd centos6.5/ [root@e3 centos6.5] # ll total dosage 8 Murray. 1 root root 2082 January 21 16:39 1421829141.xml # Storage File-rw-. 1 root root 2133 January 21 16:39 1421829551.xml # Storage Files

Restore virtual machine snapshot # virtual machine must be turned off

[root@e3 images] # virsh list-- all Id name status-29 centos6.6 running 33 centos6.5 running-kvm001 Close-kvm002 close-kvm003 close-template close [root@e3 images] # virsh shutdown centos6.5 # close domain centos6.5 is closed [root@e3 images] # virsh destroy centos6.5 # close cannot force the domain centos6.5 to be deleted [root@e3 images] # virsh list-- all # View status Id name status-29 centos6.6 running-centos6.5 Close-kvm001 close-kvm002 close-kvm003 close-template close [root@e3 images] # virsh domstate centos6.5 # confirm close close [root@e3 images] # virsh snapshot-list centos6.5 # View snapshot name Said generation time status-1421829141 2015-01-21 16:32:21 + 0800 shutoff 1421829551 2015-01-21 16:39:11 + 0800 shutoff [root E3 images] # virsh snapshot-current centos6.5 # View which snapshot is currently used 1421829551 # shutoff [root@e3 images] # virsh snapshot-revert centos6.5 1421829141 # restore [root@e3 images] # virsh snapshot-current centos6.5 1421829141 # restore successfully shutoff 1421829141 above is all the content of the article "sample Analysis of KVM Virtual Machine Snapshot Management" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 280

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report