Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 12. Grouping LVM objects with tags
You can assign tags to Logical Volume Manager (LVM) objects to group them. With this feature, you can automate the control of LVM behavior, such as activation, by a group. You can also use tags instead of LVM objects arguments.
12.1. LVM object tags Link kopierenLink in die Zwischenablage kopiert!
A Logical Volume Manager (LVM) tag groups LVM objects of the same type. You can attach tags to objects such as physical volumes, volume groups, and logical volumes , as well as to hosts in a cluster configuration .
To avoid ambiguity, prefix each tag with @. Each tag is expanded by replacing it with all the objects that possess that tag and that are of the type expected by its position on the command line.
LVM tags are strings of up to 1024 characters. LVM tags cannot start with a hyphen.
A valid tag consists of a limited range of characters only. The allowed characters are A-Z a-z 0-9 _ + . - / = ! : # &.
Only objects in a volume group can be tagged. Physical volumes lose their tags if they are removed from a volume group; this is because tags are stored as part of the volume group metadata and that is deleted when a physical volume is removed.
You can apply some commands to all volume groups (VG), logical volumes (LV), or physical volumes (PV) that have the same tag. The man page of the given command shows the syntax, such as VG|Tag, LV|Tag, or PV|Tag when you can substitute a tag name for a VG, LV, or PV name.
12.2. Listing LVM tags Link kopierenLink in die Zwischenablage kopiert!
The following example shows how to list LVM tags.
Procedure
Use the following command to list all the logical volumes with the
databasetag:lvs @database
# lvs @databaseCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the following command to list the currently active host tags:
lvm tags
# lvm tagsCopy to Clipboard Copied! Toggle word wrap Toggle overflow
12.3. Adding tags to LVM objects Link kopierenLink in die Zwischenablage kopiert!
You can add tags to LVM objects to group them by using the --addtag option with various volume management commands.
Prerequisites
-
The
lvm2package is installed.
Procedure
To add a tag to an existing PV, use:
pvchange --addtag <@tag> <PV>
# pvchange --addtag <@tag> <PV>Copy to Clipboard Copied! Toggle word wrap Toggle overflow To add a tag to an existing VG, use:
vgchange --addtag <@tag> <VG>
# vgchange --addtag <@tag> <VG>Copy to Clipboard Copied! Toggle word wrap Toggle overflow To add a tag to a VG during creation, use:
vgcreate --addtag <@tag> <VG>
# vgcreate --addtag <@tag> <VG>Copy to Clipboard Copied! Toggle word wrap Toggle overflow To add a tag to an existing LV, use:
lvchange --addtag <@tag> <LV>
# lvchange --addtag <@tag> <LV>Copy to Clipboard Copied! Toggle word wrap Toggle overflow To add a tag to a LV during creation, use:
lvcreate --addtag <@tag> ...
# lvcreate --addtag <@tag> ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow
12.4. Removing tags from LVM objects Link kopierenLink in die Zwischenablage kopiert!
If you no longer want to keep your LVM objects grouped, you can remove tags from the objects by using the --deltag option with various volume management commands.
Prerequisites
-
The
lvm2package is installed. - You have created tags on physical volumes (PV), volume groups (VG), or logical volumes (LV).
Procedure
To remove a tag from an existing PV, use:
pvchange --deltag @tag PV
# pvchange --deltag @tag PVCopy to Clipboard Copied! Toggle word wrap Toggle overflow To remove a tag from an existing VG, use:
vgchange --deltag @tag VG
# vgchange --deltag @tag VGCopy to Clipboard Copied! Toggle word wrap Toggle overflow To remove a tag from an existing LV, use:
lvchange --deltag @tag LV
# lvchange --deltag @tag LVCopy to Clipboard Copied! Toggle word wrap Toggle overflow
12.5. Defining LVM host tags Link kopierenLink in die Zwischenablage kopiert!
This procedure describes how to define LVM host tags in a cluster configuration. You can define host tags in the configuration files.
Procedure
Set
hosttags = 1in thetagssection to automatically define host tag using the machine’s host name.This allows you to use a common configuration file which can be replicated on all your machines so they hold identical copies of the file, but the behavior can differ between machines according to the host name.
For each host tag, an extra configuration file is read if it exists: lvm_hosttag.conf. If that file defines new tags, then further configuration files will be appended to the list of files to read in.
For example, the following entry in the configuration file always defines tag1, and defines tag2 if the host name is host1:
tags { tag1 { } tag2 { host_list = ["host1"] } }
tags { tag1 { } tag2 { host_list = ["host1"] } }
12.6. Controlling logical volume activation with tags Link kopierenLink in die Zwischenablage kopiert!
This procedure describes how to specify in the configuration file that only certain logical volumes should be activated on that host.
Procedure
For example, the following entry acts as a filter for activation requests (such as vgchange -ay) and only activates vg1/lvol0 and any logical volumes or volume groups with the database tag in the metadata on that host:
activation { volume_list = ["vg1/lvol0", "@database" ] }
activation { volume_list = ["vg1/lvol0", "@database" ] }
The special match @* that causes a match only if any metadata tag matches any host tag on that machine.
As another example, consider a situation where every machine in the cluster has the following entry in the configuration file:
tags { hosttags = 1 }
tags { hosttags = 1 }
If you want to activate vg1/lvol2 only on host db2, do the following:
-
Run
lvchange --addtag @db2 vg1/lvol2from any host in the cluster. -
Run
lvchange -ay vg1/lvol2.
This solution involves storing host names inside the volume group metadata.