How to configure HA-LVM Cluster using lvmlockd in RHEL 8 and above?
Environment
- Red Hat Enterprise Linux 8 and 9
- High Availability and/or Resilient Storage Add-On
- Active/Passive configuration for Shared Storage
Issue
- What are the steps to configure active/passive shared storage using
lvmlockdin RHEL 8 and higher?
Resolution
Assuming following is the cluster architecture
- Cluster node names are
node1andnode2while their respective hostnames arerh8-nd1andrh8-nd2. - Shared storage assigned to both the cluster nodes. In the following article shared storage is
mpathausing multipath. - Basic cluster setup is complete with fence resource is in
Startedstate as well as tested. - Validate the shared storage across all the cluster nodes is visible.
[rh8-nd1]# multipath -ll
mpatha (36001405dfade64e579642dca302af4f3) dm-2 LIO-ORG,2node_rhel8
size=1.0G features='0' hwhandler='1 alua' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| `- 2:0:0:0 sde 8:64 active ready running
`-+- policy='service-time 0' prio=50 status=enabled
`- 3:0:0:0 sdb 8:16 active ready running
[rh8-nd2]# multipath -ll
mpatha (36001405dfade64e579642dca302af4f3) dm-2 LIO-ORG,2node_rhel8
size=1.0G features='0' hwhandler='1 alua' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| `- 2:0:0:0 sde 8:64 active ready running
`-+- policy='service-time 0' prio=50 status=enabled
`- 3:0:0:0 sdb 8:16 active ready running
Procedure
-
Update
/etc/lvm/lvm.conffile on all the cluster nodes foruse_lvmlockdand assign its value as1use_lvmlockd = 1 -
Set the global Pacemaker parameter
no-quorum-policytofreeze:# pcs property set no-quorum-policy=freeze -
Rebuild initramfs on all the cluster nodes with the following steps :
3.1 Take backup of current initramfs file on
allof the cluster nodes.``` # cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.$(date +%m-%d-%H%M%S).bak ```3.2 Rebuild initramfs file on both of the cluster nodes.
``` # dracut -f -v ```3.3 Reboot all of the cluster nodes.
-
Once all the cluster nodes are back online, set up a dlm resource. This is a required dependency for configuring a GFS2 file system in a cluster:
# pcs resource create dlm --group locking ocf:pacemaker:controld op monitor interval=30s on-fail=fence -
Clone the locking resource group so that the resource group can be active on both nodes of the cluster:
# pcs resource clone locking interleave=true -
Set up an
lvmlockdresource as part of the locking resource group:# pcs resource create lvmlockd --group locking ocf:heartbeat:lvmlockd op monitor interval=30s on-fail=fence -
Once the
dlmandlvmlockdresources are started on all the nodes, proceed with creation on PV/VG/LV from any one of the cluster node. In the following example VG name iscluster_vgand LV name iscluster_lv.[rh8-nd1]# pvcreate /dev/mapper/mpatha Physical volume "/dev/mapper/mpatha" successfully created. [rh8-nd1]# vgcreate --shared cluster_vg /dev/mapper/mpatha Volume group "cluster_vg" successfully created VG shared_vg1 starting dlm lockspace Starting locking. Waiting until locks are ready... [rh8-nd1]# vgchange --lockstart cluster_vg VG cluster_vg starting dlm lockspace Starting locking. Waiting until locks are ready... [rh8-nd1]# lvcreate --activate sy -l 100%FREE -n cluster_lv cluster_vg Logical volume "cluster_lv" created. -
Validate the newly created LVM device:
[rh8-nd1]# vgs VG #PV #LV #SN Attr VSize VFree cluster_vg 1 1 0 wz--ns <2.00g 0 -
Create a filesystem of your requirement (ext4/xfs) over the newly created LVM device. The
mkfscommand should be executed on the cluster node on which the VG is active. -
Create a cluster resource with resource agent
ocf:heartbeat:LVM-activateso the VG can be managed by Cluster.# pcs resource create clu-vg ocf:heartbeat:LVM-activate vgname=cluster_vg lvname=cluster_lv activation_mode=exclusive vg_access_mode=lvmlockd --group HA-LVM- where the resource name is
clu-vgand resource group name isHA-LVM. These values can be updated as per your requirement.
- where the resource name is
-
Create a cluster resource with resource agent
ocf:heartbeat:Filesystemso cluster will control the mount of filesystem & will make it available on one of the cluster node.# pcs resource create clu-fs ocf:heartbeat:Filesystem device=/dev/cluster_vg/cluster_lv directory=/test fstype=xfs --group HA-LVM- where the resource name is
clu-fs, directory where the filesystem created over device/dev/cluster_vg/cluster_lvwill be mounted at/test, type of filesystem isxfsand this resource is kept in same resource group i.e.HA-LVM.
- where the resource name is
-
Validate the new cluster status:
# pcs status --full Cluster name: rh8-cluster Stack: corosync Current DC: node1 (version 2.1.6-9.1.el8_9-6fdc9deea29) - partition with quorum Last updated: Thu Apr 25 00:12:36 2024 Last change: Thu Apr 25 00:12:33 2024 by root via cibadmin on node1 2 nodes configured 3 resources configured Online: [ node1 node2 ] Full List of Resources: * fencexvm (stonith:fence_xvm): Started node1 * Clone Set: locking-clone [locking]: * Resource Group: locking:0: * dlm (ocf::pacemaker:controld): Started node1 * lvmlockd (ocf::heartbeat:lvmlockd): Started node1 * Resource Group: locking:1: * dlm (ocf::pacemaker:controld): Started node2 * lvmlockd (ocf::heartbeat:lvmlockd): Started node2 * Resource Group: HA-LVM: * clu-vg (ocf::heartbeat:LVM-activate): Started node1 * clu-fs (ocf::heartbeat:Filesystem): Started node1 Daemon Status: corosync: active/enabled pacemaker: active/enabled pcsd: active/enabled -
The VG is now activated on
node1 (rh8-nd1)and filesystem mounted on the same node. This can be validate byvgs,lvsanddfcommands. -
Configure the order constraint so to allow the
controldandlvmlockdresources to get started in a cloned group calledlocking-cloneand then theHA-LVMresource group should start:# pcs constraint order start locking-clone then HA-LVM -
Test the failover of the resource by placing the active node in
standby. This will ensure that the VG & filesystem gets started on passive node as well.# pcs node standby node1 -
To unstanby the node:
# pcs node unstandby node1
Important Points
This mode of configuring active/passive HA-LVM cluster is suitable when the setup will also be managing an active/active GFS2 filesystem. If the setup is only intended to manage active/passive filesystem, then it is recommended to either use system_id or tagging method for configuring the cluster:
- How to configure HA-LVM Cluster using system_id in RHEL 8 and above?
- How to configure HA-LVM Cluster using tagging & volume_list in RHEL 8 and above?
Possible errors that could be encountered
-
If the order constraint is missed to be added in the configuration, then the issue detailed in following KCS will be encountered: An LVM-activate resource failed to activate with the error: Cannot access VG shared_vg2 with system ID rhel8-1.examplerh.com with local 'system ID rhel8-2.examplerh.com.
-
Support for the lvmdevices command set was made available in Rhel 8.5+ and later. This command set is used to limit logical volume manager access to only LV's attached to devices listed in
/etc/lvm/devices/system.devicesfile. If you are using an LVM devices file, anduse_devicesfileis enabled inlvm.conf, additionally add the shared device to the devices file on the second node of the cluster. -
The lvmdevices is enabled by default in RHEL 9 while in RHEL 8.5+ it is disabled by default. When
lvmdevicesis enabled, ensure that the shared devices are added tolvmdeviceson passive node as well else it will result in issue as detailed in following article:
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.