When we perform experiments or tests on a virtual machine, we will inevitably encounter some unfamiliar places, create a snapshot at this time, and back up the current system status.
Once an operation error occurs, you can quickly restore the status before the error and complete the experiment.
Avoid the consequences of restarting the entire experiment or test due to a one-step error.
Of course, the snapshot function is far more than this,
(1) Definition
A snapshot is a snapshot image with read-only attributes at a specific time for a specific file system.
That is, the disk "snapshot" is the backup of the Virtual Machine disk file (vmdk) at a certain time point.
When you create a snapshot, the items that can be written now become read-only at that point.
If you have created multiple snapshots, You can have multiple recovery points for restoration.
(2) disk space usage and growth rate
The Snapshot file is very small at first (about 16 MB)
The Snapshot growth rate is determined by the write I/O frequency of the disk on the server.
(3) file types contained in snapshots
① Vm_name-Delta. vmdk
For example: exam1-rhel5.4-000001-s011.vmdk
When you create a snapshot, these are specific files.
The delta file is based on the change bitmap on vmdk. Therefore, it cannot grow to be larger than vmdk.
For example:
When rhel5.8-s001.vmdk is 1936000 K, when a snapshot is created: rhel5.8-s001.vmdk is 1935872 K
When you create a snapshot for a VM, some Delta files are created.
When snapshot is deleted or recovered in snapshot manager, these files are automatically deleted.
② Vm_name.vmsd
For example: exam1-rhel5.4.vmsd
Used to store metadata about snapshots, in text format
Including the snapshot display name (snapshot #. displayname), uid, and disk file name.
Before you create a snapshot, the initial size of the file is 0 bytes.
That is to say, as long as the snapshot is taken, the file will be increased and updated continuously.
After a snapshot is deleted, the file cannot be completely cleared. Once a snapshot is removed, the snapshot uid will still be retained.
Example:
. Encoding = "GBK" snapshot. lastuid = "7" snapshot. current = "6" snapshot. mru0.uid = "6" snapshot. mru1.uid = "7" snapshot. mru2.uid = "5" snapshot. mru3.uid = "1" snapshot0.uid = "1" snapshot0.filename = "exam1-rhel5.4-Snapshot1.vmsn" snapshot0.displayname = "rhel5.4" snapshot0.description = "the environment has just been configured, "snapshot0.createtimehigh =" 314967 "snapshot0.createtimelow ="-495362528 "snapshot0.numdisks =" 2 "snapshot0.disk0. filename = "exam1-rhel5.4.vmdk" snapshot0.disk0. node = "scsi0: 0" snapshot0.disk1. filename = "exam1-rhel5.4-swap0.vmdk" snapshot0.disk1. node = "scsi0: 1 "snapshot1.uid =" 5 "snapshot1.filename =" exam1-rhel5.4-Snapshot5.vmsn "snapshot1.parent =" 1 "snapshot1.displayname =" database Sofe 10.2.0.2 "snapshot1.description =" 1. Only database software 10.2.0.2 | 0d | 0A2, the experiment script has been uploaded to "snapshot1.createtimehigh =" 314971 "snapshot1.createtimelow =" 1951457584 "snapshot1.numdisks =" 2 "snapshot1.disk0. filename = "exam1-rhel5.4-000001.vmdk" snapshot1.disk0. node = "scsi0: 0" snapshot1.disk1. filename = "exam1-rhel5.4-swap0-000001.vmdk" snapshot1.disk1. node = "scsi0: 1 "snapshot2.uid =" 6 "snapshot2.filename =" exam1-rhel5.4-Snapshot6.vmsn "placement =" 5 "snapshot2.displayname =" orcl emrep agent "snapshot2.description =" 1. Manually created orcl | 0d | 0A2, dbca created emrep | 0d | install "snapshot2.createtimehigh =" 315010 "snapshot2.createtimelow ="-2126901256 "snapshot2.numdisks =" 2 "snapshot2.disk0. filename = "exam1-rhel5.4-000002.vmdk" snapshot2.disk0. node = "scsi0: 0" snapshot2.disk1. filename = "exam1-rhel5.4-swap0-000002.vmdk" snapshot2.disk1. node = "scsi0: 1 "snapshot3.uid =" 7 "snapshot3.filename =" exam1-rhel5.4-Snapshot7.vmsn "placement =" 6 "snapshot3.displayname =" physical urad "snapshot3.description =" orcl configured physical urad "placement =" 315133 "placement =" 1864149632 "snapshot3.numdisks =" 2 "snapshot3.disk0. filename = "exam1-rhel5.4-000003.vmdk" snapshot3.disk0. node = "scsi0: 0" snapshot3.disk1. filename = "exam1-rhel5.4-swap0-000003.vmdk" snapshot3.disk1. node = "scsi0: 1" snapshot. numsnapshots = "4"
③ Vm_name-. vmsn
For example: exam1-rhel5.4-Snapshot1.vmsn
Snapshot status file, which stores the exact running status of a VM when a snapshot is used
The file depends on whether you retain the storage of this virtual machine as part of snapshot.
If you choose to retain the storage of the virtual machine, the file is large and the maximum memory allocated to the virtual machine is
(4) Delete or restore a snapshot
-- Delete
Delete all snapshots, and all created △files areMergeTo the original vmdk of the VM and then deleted
Deletes a snapshot, Which is merged to its parent snapshot.
-- Restore
No matter which snapshot you restore, this snapshot becomes a new parent snapshot.
You can see this parent snapshot in snapshot manager. There is a label "you are here" under it"
⑸ Disk space and delete multiple snapshots
Here is an experience:
Reserve approximately 1/4 of the total disk space of the VM on the vmwarevm File System (vmfs) volume for the snapshot file.
Only one snapshot VM does not need additional disk space When deleting snapshots. However, if you have many snapshots, When you delete all snapshots
You will need additional disk space because these snapshots will be merged into the original vmdk
For example:
Assume that you want to delete all snapshots of three VMS: S1 S2 S3
First, S3 is merged to S2, and the size of S2 is increased.
Next, merge S2 to S1, and the size of S1 will also increase.
Finally, S1 will merge to the original disk file, which does not require additional disk space.
When the original disk file is updated at the end of the entire operation, the snapshot file is deleted, instead of being deleted during each merge process.
Therefore, when you delete them, a virtual machine with 20 GB snapshot files may need an additional 20 GB
Therefore, the solution to delete multiple snapshots with less disk space is to delete them one by one, starting from the VM parent-level snapshot to the sub-level snapshot.
In this way, when the snapshot is merged to the previous snapshot, only the previous snapshot is added and deleted.
Note: When a snapshot is running on the VM,Do not run Windows disk Fragment. The fragment operation will change many disk blocks and cause a rapid increase in snapshot files.
How long does the snapshot take to delete?
Snapshots that have been active for a long time (so they become very large) take a long time to delete.
The time required for deleting a snapshot depends on the activity level of the VM. When the VM is disabled, the deletion time is short.
It takes 3 to 6 hours for a GB snapshot to be merged to the original disk, which affects the performance of the VM.
For this reason, you should limit the duration of snapshot retention and delete snapshots when you do not need them.
Using snapshots to back up running virtual machines
Snapshot is a backup to some extent.
When the VM is on, the snapshot provides a good way to back up the original vmdk file.
All write operations are paused on the original file, so it is safe to copy it on another storage volume.
What is the difference between snapshot and clone?