Creating a Shared Cache Object
If you need to create several space-optimized instant snapshots for the volumes in a disk group, you may find it more convenient to create a single shared cache object in the disk group rather than a separate cache object for each snapshot.
To create a shared cache object:
-
Decide on the following characteristics that you want to allocate to the cache volume that underlies the cache object:
- The size of the cache volume should be sufficient to record changes to the parent volumes during the interval between snapshot refreshes. A suggested value is 10% of the total size of the parent volumes for a refresh interval of 24 hours.
- If redundancy is a desired characteristic of the cache volume, it should be mirrored. This increases the space that is required for the cache volume in proportion to the number of mirrors that it has.
- If the cache volume is mirrored, space is required on at least as many disks as it has mirrors. These disks should not be shared with the disks used for the parent volumes. The disks should also be chosen to avoid impacting I/O performance for critical volumes, or hindering disk group split and join operations.
-
Having decided on its characteristics, use the vxassist command to create the volume that is to be used for the cache volume. The following example creates a mirrored cache volume, cachevol, with size 1GB in the disk group, mydg, on the disks mydg16 and mydg17:
# vxassist -g mydg make cachevol 1g layout=mirror init=active \
mydg16 mydg17
The attribute init=active is specified to make the cache volume immediately available for use.
-
Use the vxmake cache command to create a cache object on top of the cache volume that you created in the previous step:
# vxmake [-g diskgroup] cache cache_object cachevolname=volume \
[regionsize=size] [autogrow=on] [highwatermark=hwmk] \ [autogrowby=agbvalue] [maxautogrow=maxagbvalue]]
If the region size, regionsize, is specified, it must be a power of 2, and be greater than or equal to 16KB (16k). If not specified, the region size of the cache is set to 64KB.
Note
All space-optimized snapshots that share the cache must have a region size that is equal to or an integer multiple of the region size set on the cache. Snapshot creation also fails if the original volume's region size is smaller than the cache's region size.
If the region size of a space-optimized snapshot differs from the region size of the cache, this can degrade the system's performance compared to the case where the region sizes are the same.
If the cache is to be allowed to grow in size as required, specify autogrow=on. By default, the ability to automatically grow the cache is turned off.
In the following example, the cache object, cobjmydg, is created over the cache volume, cachevol, the region size of the cache is set to 32KB, and the autogrow feature is enabled:
# vxmake -g mydg cache cobjmydg cachevolname=cachevol \
regionsize=32k autogrow=on
-
Having created the cache object, use the following command to enable it:
# vxcache [-g diskgroup] start cache_object
For example to start the cache object, cobjmydg:
# vxcache -g mydg start cobjmydg
For details of how to remove a cache, see Removing a Cache.
Listing the Snapshots Created on a Cache
To list the space-optimized instant snapshots that have been created on a cache object, use the following command:
# vxcache [-g diskgroup] listvol cache_object
The snapshot names are printed as a space-separated list ordered by timestamp. If two or more snapshots have the same timestamp, these snapshots are sorted in order of decreasing size.
Tuning the Autogrow Attributes
The highwatermark, autogrowby and maxautogrow attributes determine how the VxVM cache daemon (vxcached) maintains the cache if the autogrow feature has been enabled and vxcached is running:
- When cache usage reaches the high watermark value, highwatermark (default value is 90 percent), vxcached grows the size of the cache volume by the value of autogrowby (default value is 20% of the size of the cache volume in blocks). The new required cache size cannot exceed the value of maxautogrow (default value is twice the size of the cache volume in blocks).
- When cache usage reaches the high watermark value, and the new required cache size would exceed the value of maxautogrow, vxcached deletes the oldest snapshot in the cache. If there are several snapshots with the same age, the largest of these is deleted.
If the autogrow feature has been disabled:
- When cache usage reaches the high watermark value, vxcached deletes the oldest snapshot in the cache. If there are several snapshots with the same age, the largest of these is deleted. If there is only a single snapshot, this snapshot is detached and marked as invalid.
Note
The vxcached daemon does not remove snapshots that are currently open, and it does not remove the last or only snapshot in the cache.
If the cache space becomes exhausted, the snapshot is detached and marked as invalid. If this happens, the snapshot is unrecoverable and must be removed. Enabling the autogrow feature on the cache helps to avoid this situation occurring. However, for very small caches (of the order of a few megabytes), it is possible for the cache to become exhausted before the system has time to respond and grow the cache. In such cases, either increase the size of the cache manually as described in Growing and Shrinking a Cache, or use the vxcache set command to reduce the value of highwatermark as shown in this example:
# vxcache -g mydg set highwatermark=60 cobjmydg
You can use the maxautogrow attribute to limit the maximum size to which a cache can grow. To estimate this size, consider how much the contents of each source volume are likely to change between snapshot refreshes, and allow some additional space for contingency.
If necessary, you can use the vxcache set command to change other autogrow attribute values for a cache. See the vxcache(1M) manual page for details.
Caution
Ensure that the cache is sufficiently large, and that the autogrow attributes are configured correctly for your needs.
Growing and Shrinking a Cache
You can use the vxcache command to increase the size of the cache volume that is associated with a cache object:
# vxcache [-g diskgroup] growcacheto cache_object size
For example, to increase the size of the cache volume associated with the cache object, mycache, to 2GB, you would use the following command:
# vxcache -g mydg growcacheto mycache 2g
To grow a cache by a specified amount, use the following form of the command shown here:
# vxcache [-g diskgroup] growcacheby cache_object size
For example, the following command increases the size of mycache by 1GB:
# vxcache -g mydg growcacheby mycache 1g
You can similarly use the shrinkcacheby and shrinkcacheto operations to reduce the size of a cache. See the vxcache(1M) manual page for more information.
Removing a Cache
To remove a cache completely, including the cache object, its cache volume and all space-optimized snapshots that use the cache:
-
Run the following command to find out the names of the top-level snapshot volumes that are configured on the cache object:
# vxprint -g diskgroup -vne \
"v_plex.pl_subdisk.sd_dm_name ~ /cache_object/"
where cache_object is the name of the cache object.
-
Remove all the top-level snapshots and their dependent snapshots (this can be done with a single command):
# vxedit -g diskgroup -r rm snapvol ...
where snapvol is the name of a top-level snapshot volume.
-
Stop the cache object:
# vxcache -g diskgroup stop cache_object
-
Finally, remove the cache object and its cache volume:
# vxedit -g diskgroup -r rm cache_object
|