ALCAT的专栏

点滴记录,时刻进步!

VMware的Snapshot(快照)相关知识

最近在研究VMware的快照的相关知识,在这里做个记录和分享。

先简单介绍下快照。

A snapshot preserves the state and data of a virtual machine at a special point in time.

1) 快照保存了虚拟机在特定时间点的power state;

2) 还有就是数据。比如内存信息,所以当你做了个memory snapshot的时候,那个快照文件.vmsn的大小和你分配给虚拟机的内存大小几乎一样。

当你做了快照之后,VMware就创建一个child disk(sparse disk),之后虚拟机的数据变更都会写在这个child disk中,而base disk就变成只读的了。

base disk 和那个快照文件.vmsn就可以还原快照时的状态。

下面是一个老外写的关于快照配置文件的一些内容。

VMware records snapshot information about the current VM in a .vmsd file. This file is located with the rest of the virtual machine configuration and VMDK files on the datastore. The file is normally called .vmsd. This file will contain information, even if your VM has no snapshots in place.

It is possible that in some cases, ESX fails to properly clean up after previous snapshots were removed. The information for previous snapshots may still be recorded in the .vmsd file. The file may indicate that you still have snapshots in pace, although all previous snapshots were removed and the dalta files have been merged. When you then try to create a snapshot, the .vmsd file will inform the ESX host that there is a delta file in place and that it has to create a second or third delta file. When the ESX host interigates the VMFS file system, it's unable to find the snapshot delta files specified in the .vmsd file and therefore errors with "an invalid snapshot configuration was detected."

We need to clear the contents of the .vmsd file in order to create new snapshots.

 

How to fix the issue

Create a backup copy of the current .vmsd file. Then create a new file called.vmsd. This can be done with a single command from the VMware ESX CLI (Service Console) once you have browsed to the datastore where the VM resides:

    cd /vmfs/volumes///
    mv ./.vmsd ./.vmsd.old && touch ./.vmsd


Let's just have a look at the commands above

mv : This renames the .vmsd file.

&& : This basically tells the CLI that if the "mv" command was executed and completed successfully, only then execute the next part of the command which is "touch".

touch: "touch" is a Linux command that simply creates an empty file.

So, with a single line we have renamed (created a backup) our original file and created a new file that has the original file's name.

After the new .vmsd file has been created, it need to be initialised. In order to do so, use the VI client to create a snapshot. Once the new snapshot has been created, go ahead and delete the new snapshots again. This will write some information to the .vmsd file:

    .encoding = "UTF-8"
    snapshot.lastUID = "2"
    snapshot.numSnapshots = "0"
    snapshot.current = "0"
    snapshot0.uid = "2"
    snapshot0.filename = "-Snapshot2.vmsn"
    snapshot0.displayName = "Consolidate Helper- 0"
    snapshot0.description = "Helper snapshot for online consolidate."
    snapshot0.createTimeHigh = "290676"
    snapshot0.createTimeLow = "861410424"
    snapshot0.numDisks = "2"
    snapshot0.disk0.fileName = ".vmdk"
    snapshot0.disk0.node = "scsi0:0"
    snapshot0.disk1.fileName = "_1.vmdk"
    snapshot0.disk1.node = "scsi0:1"
    snapshot.needConsolidate = "FALSE"

 The issue should now be resolved and snapshots should work as expected.

VMware中和快照相关的信息都保存在那个".vmsd "文件中了,即使没有创建快照,这个文件依旧存在,不过里面的内容只有简单的2行:

.encoding = "UTF-8"
snapshot.lastUID = "2"

而VMware是根据这个文件来定位快照的,所以即使你创建了N多快照,然后将该文件重新修改,那么就有可能找不到这些快照。或者你根本就没有快照,但是这个文件中的信息显示有快照,那么VMware还是会显示有快照,只是当你对快照做操作时,会提示“快照文件配置出错”之类的信息。
阅读更多
个人分类: VMware
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭