5.5. Creating a Mirrored LVM Logical Volume in a Cluster Creating a mirrored LVM logical volume in a cluster requires the same commands and procedures as creating a mirrored LVM logical volume on a single node with a segment type of mirror . However, in order to create a mirrored LVM volume in a cluster: The cluster and cluster mirror infrastructure must be running The cluster must be quorate The locking type in the lvm.conf file must be set correctly to enable cluster locking and the use_lvmetad setting should be 0. Note, however, that in Red Hat Enterprise Linux 7 the ocf:heartbeat:clvm Pacemaker resource agent itself, as part of the start procedure, performs these tasks. In Red Hat Enterprise Linux 7, clusters are managed through Pacemaker. Clustered LVM logical volumes are supported only in conjunction with Pacemaker clusters, and must be configured as cluster resources. The following procedure creates a mirrored LVM volume in a cluster. Install the cluster software and LVM packages, start the cluster software, and create the cluster. You must configure fencing for the cluster. The document High Availability Add-On Administration provides a sample procedure for creating a cluster and configuring fencing for the nodes in the cluster. The document High Availability Add-On Reference provides more detailed information about the components of cluster configuration. In order to create a mirrored logical volume that is shared by all of the nodes in a cluster, the locking type must be set correctly in the lvm.conf file in every node of the cluster. By default, the locking type is set to local. To change this, execute the following command in each node of the cluster to enable clustered locking: Set up a dlm resource for the cluster. You create the resource as a cloned resource so that it will run on every node in the cluster. Configure clvmd as a cluster resource. Just as for the dlm resource, you create the resource as a cloned resource so that it will run on every node in the cluster. Note that you must set the with_cmirrord=true parameter to enable the cmirrord daemon on all of the nodes that clvmd runs on. If you have already configured a clvmd resource but did not specify the with_cmirrord=true parameter, you can update the resource to include the parameter with the following command. Set up clvmd and dlm dependency and start up order. clvmd must start after dlm and must run on the same node as dlm . Create the mirror. The first step is creating the physical volumes. The following commands create three physical volumes. Two of the physical volumes will be used for the legs of the mirror, and the third physical volume will contain the mirror log. Create the volume group. This example creates a volume group vg001 that consists of the three physical volumes that were created in the step. Note that the output of the vgcreate command indicates that the volume group is clustered. You can verify that a volume group is clustered with the vgs command, which will show the volume group's attributes. If a volume group is clustered, it will show a c attribute. Create the mirrored logical volume. This example creates the logical volume mirrorlv from the volume group vg001 . This volume has one mirror leg. This example specifies which extents of the physical volume will be used for the logical volume. You can use the lvs command to display the progress of the mirror creation. The following example shows that the mirror is 47% synced, then 91% synced, then 100% synced when the mirror is complete. The completion of the mirror is noted in the system log: You can use the lvs command with the -o +devices options to display the configuration of the mirror, including which devices make up the mirror legs. You can see that the logical volume in this example is composed of two linear images and one log. You can use the seg_pe_ranges option of the lvs to display the data layout. You can use this option to verify that your layout is properly redundant. The output of this command displays PE ranges in the same format that the lvcreate and lvresize commands take as input. Note For information on recovering from the failure of one of the legs of an LVM mirrored volume, see Section 6.2, "Recovering from LVM Mirror Failure" .

Commands:
/sbin/lvmconf --enable-cluster
pcs resource create dlm ocf:pacemaker:controld op monitor interval=30s on-fail=fence clone interleave=true ordered=true
pcs resource create clvmd ocf:heartbeat:clvm with_cmirrord=true op monitor interval=30s on-fail=fence clone interleave=true ordered=true
pcs resource update clvmd with_cmirrord=true
pcs constraint order start dlm-clone then clvmd-clone pcs constraint colocation add clvmd-clone with dlm-clone
pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created pvcreate /dev/sdc1 Physical volume "/dev/sdc1" successfully created pvcreate /dev/sdd1 Physical volume "/dev/sdd1" successfully created
vgcreate vg001 /dev/sdb1 /dev/sdc1 /dev/sdd1 Clustered volume group "vg001" successfully created
vgs vg001 VG #PV #LV #SN Attr VSize VFree vg001 3 0 0 wz--nc 68.97G 68.97G
lvcreate --type mirror -l 1000 -m 1 vg001 -n mirrorlv /dev/sdb1:1-1000 /dev/sdc1:1-1000 /dev/sdd1:0 Logical volume "mirrorlv" created
lvs vg001/mirrorlv LV VG Attr LSize Origin Snap% Move Log Copy% Convert mirrorlv vg001 mwi-a- 3.91G vg001_mlog 47.00 lvs vg001/mirrorlv LV VG Attr LSize Origin Snap% Move Log Copy% Convert mirrorlv vg001 mwi-a- 3.91G vg001_mlog 91.00 lvs vg001/mirrorlv LV VG Attr LSize Origin Snap% Move Log Copy% Convert mirrorlv vg001 mwi-a- 3.91G vg001_mlog 100.00
May 10 14:52:52 doc-07 [19402]: Monitoring mirror device vg001-mirrorlv for events May 10 14:55:00 doc-07 lvm[19402]: vg001-mirrorlv is now in-sync
lvs -a -o +devices LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices mirrorlv vg001 mwi-a- 3.91G mirrorlv_mlog 100.00 mirrorlv_mimage_0(0),mirrorlv_mimage_1(0) [mirrorlv_mimage_0] vg001 iwi-ao 3.91G /dev/sdb1(1) [mirrorlv_mimage_1] vg001 iwi-ao 3.91G /dev/sdc1(1) [mirrorlv_mlog] vg001 lwi-ao 4.00M /dev/sdd1(0)
lvs -a -o +seg_pe_ranges --segments PE Ranges mirrorlv_mimage_0:0-999 mirrorlv_mimage_1:0-999 /dev/sdb1:1-1000 /dev/sdc1:1-1000 /dev/sdd1:0-0