Saturday, October 1, 2011

Veritas Volume Manager

Generic Tasks

Assumption: Veritas software has been installed and that rootdg has been setup by the installer with a minimum of one disk. If not, install the software now.

Use the "format" command to display available disks. If necessary, add new disks to the system and run "drvconfig; devlinks; disks" to configure the new disks. Do not partition disks to be used by Veritas.

To display disks setup for Veritas, use the command "vxdisk list".

To add more disks to the control of Veritas, use the following command:

vxdiskadd

The would be c2t0d0, for example, without the slice suffix. The vxdiskadd script will prompt for necessary information such as the name of the disk group, whether or not to initialize the new disk, etc. Rerun the command "vxdisk list" to view the new disk.

To designate an unused disk as a hot-spare disk, use the following command:

vxedit set spare=on

The would be the Veritas name for the disk, such as disk01. Use "vxdisk list" to confirm that the disk is now a dedicated hot-spare disk. To remove the disk from the dedicated hot-spare pool, use the following command:

vxedit set spare=off

By default, Veritas will name disks based on the name of the disk group. To rename a disk (for example, from disk01 to disk02), use the following command:

vxedit rename

To place a disk offline (for example, if the disk has become corrupted), run the following command:

vxdisk offline

The would be c2t0d0, for example, without the slice suffix.
To remove a disk from the diskgroup to which it belongs, run the following command:

vxdg [-g diskgroup name] rmdisk

To then remove that disk from Veritas control entirely, run the following command:

vxdisk rm

The same set of commands may be used to move disks from one diskgroup to another:

vxdg rmdisk
vxdg -g adddisk =
(For example, "vxdg -g ttdg adddisk ttdg01=c1t0d0".)

Alternatively, you can simply remove the disk from Veritas control and then reinitialize it with "vxdiskadd". Use "vxdisk list" to confirm the new affiliation.
Every disk group requires a minimum of one disk. The simplest way to add a new diskgroup is to run the "vxdiskadd" command on an unconfigured disk, and when prompted for the name of the diskgroup to use, enter the desired name of the new diskgroup.

To display information on disk groups, run "vxdg list" or "vxdg list".

To destroy a diskgroup and reuse the disks for other purposes, run the following command:

vxdg destroy

Failing or failed disks can be removed with the "vxdiskadm" menu command. To remove a failing disk, select choice 4, "remove a disk for replacement". To replace the disk later, select choice 5, "replace a failed or removed disk".

The Volumes Tips and Tricks

The basic command used to create volumes is "vxassist". The format is "vxassist make". The length can be specified in units of kilobytes, megabytes, or gigabytes with the suffixes k, m, or g. By default, new volumes are created from rootdg. Use "-g" to specify a different diskgroup.

To determine the maximum size that a new volume could be given particular attributes, use the "vxassist maxsize" command. For example, to determine the maximum size of a striped volume using disk01 and disk02:

vxassist maxsize layout=stripe disk01 disk02

Then create the volume using that length. For example: vxassist make vol01 20g layout=stripe disk01 disk02
By default, the "vxassist" command creates concatenated volumes. For example, the command "vxassist make newvol 10m" would create a concatenated volume with the length of 10 MB. To specify the disk(s) to use, add the disk name(s). For example, "vxassist make newvol 10m disk01".

To create striped volumes, add the attribute "layout=stripe". For exampke, "vxassist make newvol 10g layout=stripe disk01 disk02".

To create RAID-5 volumes, add the attribute "layout=raid5". For example, "vxassist make newvol 30g layout=raid5".

To create mirrored volumes, add the attribute "layout=mirror". For example, "vxassist make newvol 10g layout=mirror".

The "vxassist" command can be used to grow or shrink the size of volumes. Do not shrink the size of volumes below the size of the filesystem. To grow volumes, run one of the following commands:

vxassist growto
vxassist growby


Similarly, you can shrink the size of volumes:

vxassist shrinkto
vxassist shrinkby

To remove an unneeded volume, unmount any filesystems on the volume, remove any references to the volume from /etc/vfstab, stop the volume with "vxvol stop", and then run "vxedit -rf rm" or "vxassist
remove volume".

Existing volumes can be mirrored to add redundancy. To mirror existing volumes, use the following command:

vxassist mirror

To remove a mirror (more precisely, to remove one of the plexes from the volume), use the following command:

vxplex -o rm

To stop volumes, use the command "vxvol stop". To stop all volumes, run the command "vxvol stopall". To restart volumes, use the command "vxrecover -s" or use the command Veritas will automatically allocate the necessary space from unused disks. The process may take some time depending on the size of the volume. When fully synchronized, the status of the snapshot mirror will change to SNAPDONE. Use the following command to monitor the progress of the snapshot:

vxtask -l list

2. Detach the snapshot and create the new read-only snapshot volume with the following command:

vxassist snapshot

The period required to create the snapshot volume is shorter but it is preferred to limit I/O to the volume during the period required.

3. Clean the contents of the new snapshot volume with the following command:

fsck -y /dev/vx/rdsk/

4. Mount the snapshot volume, perform the backup, unmount the volume, and then remove the snapshot volume to save space with the following command:

vxedit -rf rm

Diskgroups tips and Tirkcs

Diskgroups can be moved from one system to another system. On the original system, unmount any volumes in the disk group to be deported and stop them with the command "vxvol stop". Then deport the disk group with the command "vxdg deport".

Move the disks physically to the new system and either reboot the system so that Veritas recognizes the new disks, or use the command "vxdctl enable" to restart vxconfigd.

Import the disks with the command "vxdg import". Then restart all volumes in the disk group with the command "vxrecover -g -sb".

To rename diskgroups during deport/import, run the deport/import command with the argument "-n ". After importing the diskgroup, run the command "vxprint -hrt". The volumes that belong to the imported disk group may be DISABLED. Run the command "vxinfo "volume name" to be sure that the volumes are "startable". Then run "vxrecover -s" to enable each volume.

If the disks in question have been moved due to the crash of the original system, then they will not have been properly deported and will be locked. To unlock the disks, run the command "vxdisk clearimport" or "vxdg -C import". Be sure not to run these commands if the original system has physical access to the disks since that would allow access to the disks from multiple hosts and possibly cause data corruption.

 Performance tips and tricks

The performance of Veritas volumes can be monitored with the "vxstat" command. Reset the volume statistics with the command "vxstat -r", let the system run normally for several hours, and then run "vxstat" and check the read/write performance. If you see two or more heavily used volumes on the same physical disk, you may want to move one of the volumes to an unused disk. To do so, use the following command:

vxassist !

You do not have to specify the new disk name. In that case, the volume will be moved to any available disk. For example, to move the volume called archive from disk03 to disk04, run the following command:

vxassist move archive !disk03 disk04

If one volume is particularly heavily used, you may want to convert from the default concatenation to striping. To do so, create a striped plex (mirror) of the volume and then remove the old (concatenated) plex. For example, to convert the volume called archive from concatenated to striped, run the following commands:

vxassist mirror archive layout=stripe disk02 disk03 disk04 vxplex -o rm dis archive-01

How-To Remove mirroring

To remove a mirror from a volume (i.e., to remove one of the plexes that belongs to the volume), run the following command:

vxplex -o rm dis

Any associated subdisks will then become available for other uses. To remove the disk from Volume Manager control entirely, run the following command:

vxdisk rm

For example, "vxdisk rm c1t1d0s2".

How-To Delete Volume

To remove a volume, unmount any filesystems on the volume and run the following command:
vxassist remove volume

How-To Mirror Backup

The following techniques can be used to backup mirrored volumes by temporarily taking one of the mirrors offline and then reattaching the mirror to the volume once the backup has been run.

1. Disassociate one of the mirrors from the volume to be backed up:

vxplex dis

2. Create a new, temporary volume using the disassociated plex:

vxmake -g -U gen vol tempvol plex=

3. Start the new volume:

xvol start tempvol

4. Clean the new volume before mounting:

fsck -y /dev/vx/rdsk//tempvol

5. Mount the new volume and perform the backup

6. Unmount the new volume

7. Stop the new volume:

vxvol stop tempvol

8. Disassociate the plex from the new volume:

vxplex dis

9. Reattach the plex to the original volume:

xplex att

10. Delete the temporary volume:

vxedit rm tempvol

To display the current Veritas configuration, use the following command:

vxprint

To monitor the progress of tasks, use the following command:

vxtask -l list

To display information related to plexes, run the following command:

vxprint -lp

How-To Export-Deport

Disk groups can be moved from one system to another with the deport/import commands. The same technique can be used to rename a disk group by deporting the disk group with a new name.
1. Unmount any filesystems on the disk group

2. Stop any volumes on the disk group:

vxvol stop

3. Deport the disk group:

vxdg deport

4. Import the disk group:

vxdg import

5. Restart and resynchronize the disk group:

vxrecover -g -sb

6. Remount any filesystems from the disk group
If you have any problems, check the status of volumes on the disk group:

vxinfo
To rename the disk group during deport/import, use the -n argument:

vxdg deport -n