设为首页 收藏本站
查看: 925|回复: 0

[经验分享] VMware的Snapshot(快照)相关知识

[复制链接]

尚未签到

发表于 2018-6-6 20:42:06 | 显示全部楼层 |阅读模式
  最近在研究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还是会显示有快照,只是当你对快照做操作时,会提示“快照文件配置出错”之类的信息。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-519782-1-1.html 上篇帖子: SCVMM2012 SP1 添加VMware vCenter服务器 下篇帖子: Vmware安装linux5.5虚拟机
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表