分类:
2006-11-08 21:37:38
在ESX3.0中,Service Console备份和恢复VM使用的是vcbMounter和vcbRestore. 他们实际上是vmsnap.pl的升级版。例如你在COS下输入vmsnap.pl命令:
[root@BI-ESX1 SFU]# vmsnap.pl
vmsnap.pl has been deprecated with this release of ESX.
Please use vcbMounter instead.
Refer to the ESX backup guide for details.
但他们的原理实际上是一样的,大概过程如下:
1) Virtual Center自动建立VM的快照
2) 对快照进行备份
3) 备份完成后自动删除快照
备份之前必须编辑好/etc/vmware/backuptools.cfg, 这里面需要制定Virtual Center的地址,管理帐号等,因为需要用来启动快照。这些选项也可以在命令行中指定。
整个测试的过程如下:
v 备份测试
[root@BI-ESX1 tmp]# vcbMounter -a ipaddr:192.168.0.222 -r /vmimages/tmp/SFU
[2006-11-08 10:57:35.356 'App' 3076456576 info] Current working directory: /vmimages/tmp
[2006-11-08 10:57:35.386 'BaseLibs' 4770736 warning] [Vmdb_Unset] Unsetting unknown path: /vmomi/
Copying "[FC_Test_2TLUN] SFU-Test/SFU-Test.vmx":
0%=====================50%=====================100%
**************************************************
Copying "[FC_Test_2TLUN] SFU-Test/SFU-Test.nvram":
0%=====================50%=====================100%
**************************************************
Copying "[FC_Test_2TLUN] SFU-Test//vmware-1.log":
0%=====================50%=====================100%
**************************************************
Copying "[FC_Test_2TLUN] SFU-Test//vmware.log":
0%=====================50%=====================100%
**************************************************
Converting "/vmimages/tmp/SFU/scsi0-0-0-SFU-Test.vmdk" (compact file):
0%=====================50%=====================100%
**************************************************
[root@BI-ESX1 SFU]# ls -l /vmimages/tmp/SFU
total 2699496
-rw-r--r-- 1 root root 766 Nov 8 10:57 catalog
-rw------- 1 root root 1623523328 Nov 8 11:26 scsi0-0-0-SFU-Test-s001.vmdk
-rw------- 1 root root 1138032640 Nov 8 11:26 scsi0-0-0-SFU-Test-s002.vmdk
-rw------- 1 root root 65536 Nov 8 11:26 scsi0-0-0-SFU-Test-s003.vmdk
-rw------- 1 root root 461 Nov 8 11:26 scsi0-0-0-SFU-Test.vmdk
-rw------- 1 root root 8664 Nov 8 10:57 SFU-Test.nvram
-rw------- 1 root root 1490 Nov 8 10:57 SFU-Test.vmx
-rw-r--r-- 1 root root 54 Nov 8 11:26 unmount.dat
-rw------- 1 root root 50403 Nov 8 10:57 vmware-1.log
-rw------- 1 root root 28568 Nov 8 10:57 vmware.log
v 恢复测试
如果是恢复到原来的位置,那么直接vcbRestore -s /vmimages/tmp/SFU就可以了,以下的例子是恢复到另外一个DataStore
1) 拷贝一份新的catalog
# cp /vmimages/tmp/SFU/catalog /tmp/catalog-SFU
2) 修改新的catalog catalog-SFU
备份生成的catalog文件/vmimages/tmp/SFU/catalog为;
version= esx-3.0
state= poweredOn
display_name= "SFU-Test"
uuid= "502cf7d9-b517
disk.scsi0:0.filename= "scsi0-0-0-SFU-Test.vmdk"
disk.scsi0:0.diskname= "[FC_Test_2TLUN] SFU-Test/SFU-Test.vmdk"
config.vmx= "[FC_Test_2TLUN] SFU-Test/SFU-Test.vmx"
host= bi-esx1
timestamp= "Wed Nov 8 10:57:43 2006"
config.suspenddir= "[FC_Test_2TLUN] SFU-Test/"
config.snapshotdir= "[FC_Test_2TLUN] SFU-Test/"
config.file0= "SFU-Test.vmsd"
config.file1= "SFU-Test.vmxf"
config.file2= "SFU-Test.nvram"
config.logdir= "[FC_Test_2TLUN] SFU-Test/"
config.log0= "vmware-1.log"
config.log1= "vmware.log"
folderpath= "/Hosts & Clusters/COMPANY Datacenter/vm/Test VMs"
resourcepool= "/Hosts & Clusters/COMPANY Datacenter/host/COMPANY Datacenter HA & DRS/Resources"
使用vi修改,命令为1,$ s/FC_Test_2TLUN/iSCSI_Test_2TLUN/g
修改后的文件/tmp/catalog-SFU为:
version= esx-3.0
state= poweredOn
display_name= "SFU-Test"
uuid= "502cf7d9-b517
disk.scsi0:0.filename= "scsi0-0-0-SFU-Test.vmdk"
disk.scsi0:0.diskname= "[iSCSI_Test_2TLUN] SFU-Test/SFU-Test.vmdk"
config.vmx= "[iSCSI_Test_2TLUN] SFU-Test/SFU-Test.vmx"
host= bi-esx1
timestamp= "Wed Nov 8 10:57:43 2006"
config.suspenddir= "[iSCSI_Test_2TLUN] SFU-Test/"
config.snapshotdir= "[iSCSI_Test_2TLUN] SFU-Test/"
config.file0= "SFU-Test.vmsd"
config.file1= "SFU-Test.vmxf"
config.file2= "SFU-Test.nvram"
config.logdir= "[iSCSI_Test_2TLUN] SFU-Test/"
config.log0= "vmware-1.log"
config.log1= "vmware.log"
folderpath= "/Hosts & Clusters/COMPANY Datacenter/vm/Test VMs"
resourcepool= "/Hosts & Clusters/COMPANY Datacenter/host/COMPANY Datacenter HA & DRS/Resources"
3) 使用新的catalog恢复
[root@BI-ESX1 /]# vcbRestore -s /vmimages/tmp/SFU -a /tmp/catalog-SFU
[2006-11-08 12:16:15.656 'App' 3076456576 info] Current working directory: /
[2006-11-08 12:16:15.732 'BaseLibs' 8317872 warning] [Vmdb_Unset] Unsetting unknown path: /vmomi/
Converting "/vmfs/volumes/iSCSI_Test_2TLUN/SFU-Test/SFU-Test.vmdk" (VMFS (flat))
:
0%=====================50%=====================100%
**************************************************
注意的问题:
1) 使用vcbMounter备份的VM必须用vcbRestore恢复
这和使用vmkfstools export的VM也必须用vmkfstools来import同理.但VCB的备份由于使用了snapshot技术,因此可以备份power on的VM。
2) UUID
如果你将备份的VM恢复到同一台ESX上,就会出现两台VM具有同样的UUID,系统检测到后会提示,你就选择create new就可以了。当然,即使恢复到不同的ESX, IP也同样会冲突。
3) 备份时制定的目录不需要事先建立
如-r /vmimages/tmp/SFU中的SFU目录,VCB命令会自动建立。
4) 可以使用vcbSnapAll来备份满足特定条件的多个虚拟机
5) 通过选项可以备份/恢复到本地目录(file://)或远端的Server(scp://)。