Tuesday, October 18, 2011

Managing Duplicate VMFS Datastores with vicfg-volume

Managing Duplicate VMFS Datastores with vicfg-volume
Each VMFS datastore created in a LUN has a unique UUID that is stored in the file system superblock. When the LUN is replicated or a snapshot made, the resulting LUN copy is identical, byteforbyte, to the original LUN. As a result, if the original LUN contains a VMFS datastore with UUID X, the LUN copy appears to contain an identical VMFS datastore, or a VMFS datastore copy, with the same UUID X.
ESX/ESXi hosts can determine whether a LUN contains the VMFS datastore copy, and either mount the datastore copy with its original UUID or change the UUID to resignature the datastore. When a LUN contains a VMFS datastore copy, you can mount the datastore with the existing signature or assign a new signature. The ESX Configuration Guide and the ESXi Configuration Guide discuss volume resignaturing in detail.

Mounting Datastores with Existing Signatures
You can mount a VMFS datastore copy without changing its signature if the original is not mounted. For example, you can maintain synchronized copies of virtual machines at a secondary site as part of a disaster recovery plan. In the event of a disaster at the primary site, you can mount the datastore copy and power on the virtual machines at the secondary site.

IMPORTANT You can mount a VMFS datastore only if it does not conflict with an already mounted VMFS datastore that has the same UUID.

When you mount the VMFS datastore, ESX/ESXi allows both read and write operations to the datastore residing on the LUN copy. The LUN copy must be writable. The datastore mounts are persistent and valid across system reboots. Because ESX/ESXi prevents you from resignaturing the mounted datastore, unmount the datastore before resignaturing.

To mount a datastore
1 List all volumes that have been detected as snapshots or replicas.
vicfg-volume <conn_options> --list

C:\>vicfg-volume.pl  --server vcenter --username Administrator --vihost esx1.virtuallab.com  --list
Enter password:
VMFS3 UUID/label: 4e9bcbe0-7d6a07b5-adef-000c29f15a5b/iSCSI_VMFS1
Can mount: No (the original volume is still online)
Can resignature: Yes
Extent name: t10.F405E46494C45400C4C624C434A6D23376C647D215E4C403:1     range: 0 - 3839 (MB)


C:\>vicfg-volume.pl  --server vcenter --username Administrator --vihost esx2.virtuallab.com  --list
Enter password:

2 Run vicfg-volume --persistent-mount with the VMFSUUID or label as an argument to mount a volume.
vicfg-volume <conn_options> --persistent-mount <VMFS-UUID|label>

C:\>vicfg-volume.pl --server esx1 --username root --persistent-mount  4e9bcbe0-7d6a07b5-adef-000c29f15a5b
Enter password:
Persistently mounting volume 4e9bcbe0-7d6a07b5-adef-000c29f15a5b
persistent-mount failed: Cannot change the host configuration.

C:\>vicfg-volume.pl --server esx1 --username root --persistent-mount  iSCSI_VMFS1
Enter password:
Persistently mounting volume iSCSI_VMFS1
persistent-mount failed: Cannot change the host configuration.

Above commands failed because the original copy is online.

You can later run vicfg-volume --unmount to unmount the snapshot or replica volume.

vicfg-volume <conn_options> --unmount <VMFS-UUID|label>

The vicfg-volume command supports resignaturing a snapshot volume and mounting and unmounting the volume. You can also make the mounted volume persistent across reboots and query a list of snapshot volumes and original volumes.



Resignaturing VMFS Copies
Use datastore resignaturing to retain the data stored on the VMFS datastore copy. When resignaturing a VMFS copy, the ESX/ESXi host assigns a new UUID and a new label to the copy, and mounts the copy as a datastore distinct from the original.
The default format of the new label assigned to the datastore is snap-<snapID>-<oldLabel>, where <snapID> is an integer and <oldLabel> is the label of the original datastore.
When you perform datastore resignaturing, consider the following points:
n Datastore resignaturing is irreversible.
n The LUN copy that contains the VMFS datastore that you resignature is no longer treated as a LUN copy.
n A spanned datastore can be resignatured only if all its extents are online.
n The resignaturing process is crash and fault tolerant. If the process is interrupted, you can resume it later.
n You can mount the new VMFS datastore without a risk of its UUID conflicting with UUIDs of any other datastore, such as an ancestor or child in a hierarchy of LUN snapshots.

To resignature a VMFS copy
1 Make sure the copy is not mounted.
2 Run vicfg-volume with the resignature option.
vicfg-volume <conn_options> --resignature <VMFS-UUID|label>

C:\>vicfg-volume.pl --server esx1 --username root --resignature  4e9bcbe0-7d6a07b5-adef-000c29f15a5b
Enter password:
Resignaturing volume 4e9bcbe0-7d6a07b5-adef-000c29f15a5b

After resinaturing, vicfg-volumes  <conn_options>  --list does not display the resignatured volume as snapshot/replica.
C:\>vicfg-volume.pl  --server vcenter --username Administrator --vihost esx1.virtuallab.com  --list
Enter password:

Mounted datastore after resignaturing. See volume identifier. It has snap-<snapID>-<oldLabel> format.

C:\>vicfg-volume.pl --server esx1 --username root --umount snap-38627f78-iSCSI_VMFS1
Enter password:
Can't umount normal VMFS3 volumes. This option is only valid for snapshot/replica volumes which are manually mounted.

Resignatured volume cannot be unmounted using vicfg-volume command.


<Scenario #2>
C:\>vicfg-volume.pl  --server vcenter --username Administrator --vihost esx1.virtuallab.com  --list
Enter password:
VMFS3 UUID/label: 4e9bcbe0-7d6a07b5-adef-000c29f15a5b/iSCSI_VMFS1
Can mount: No (the original volume is still online)
Can resignature: Yes
Extent name: t10.F405E46494C45400C4C624C434A6D23376C647D215E4C403:1     range: 0 - 3839 (MB)

When there is snapshot volume, you can see it in the add storage user interface of vSphere client.
LUN 3 has the same VMFS label of original volume.

Try to delete the original volume. To simulate volume problem, let's remove iSCSI_VMFS1 datastore.

After removing original volume, snapshot volume can be mounted.
C:\>vicfg-volume.pl --server esx1 --username root --persistent-mount  4e9bcbe0-7d6a07b5-adef-000c29f15a5b
Enter password:
Persistently mounting volume 4e9bcbe0-7d6a07b5-adef-000c29f15a5b

Remember that sanpshot volume cannot be mounted while the original volume is online. See iSCSI_VMFS1 datastore is snaposhot but it is shown as if it is the original volume after removing the original volume. So snapshot/replica can be used as backup at DR center if the UUID of volume does not conflict with existing UUIDs in the vCenter environment.


Mounted snapshot can be unmounted although it is shown like the original volume.
C:\>vicfg-volume.pl --server esx1 --username root --umount iSCSI_VMFS1
Enter password:
Umounting volume /vmfs/volumes/iSCSI_VMFS1



<Scenario#3>

Mount snapshot volume after removing the original volume.
C:\>vicfg-volume.pl --server esx1 --username root --persistent-mount  4e9bcbe0-7d6a07b5-adef-000c29f15a5b
Enter password:
Persistently mounting volume 4e9bcbe0-7d6a07b5-adef-000c29f15a5b

and then add new datastore with deleted original volume of snapshot as iSCSI_VMFS2(different datastore name).
You can see iSCSI_VMFS1, iSCSI_VMFS2 datastore. iSCSI_VMFS1 is the snapshot and iSCSI_VMFS2 is the original volume. But iSCSI_VMFS2 is added after removing so it has different UUID.

On the other host in a cluster, mounted snapshot datastore is not displayed after clicking 'refresh'.

C:\>vicfg-volume.pl --server esx1 --username root --umount iSCSI_VMFS1
Enter password:
Umounting volume /vmfs/volumes/iSCSI_VMFS1

C:\>vicfg-volume.pl --server esx1 --username root --resignature  4e9bcbe0-7d6a07b5-adef-000c29f15a5b
Enter password:
Resignaturing volume 4e9bcbe0-7d6a07b5-adef-000c29f15a5b

After resignaturing the snapshot, it is displayed on the other host in a cluster. It has the resignatured format of identifier.

No comments: