How to configure HA-LVM Cluster using lvmlockd in RHEL 8 and above?

Solution Verified - Updated

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 lvmlockd in RHEL 8 and higher?

Resolution

Assuming following is the cluster architecture

  • Cluster node names are node1 and node2 while their respective hostnames are rh8-nd1 and rh8-nd2.
  • Shared storage assigned to both the cluster nodes. In the following article shared storage is mpatha using multipath.
  • Basic cluster setup is complete with fence resource is in Started state 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

  1. Update /etc/lvm/lvm.conf file on all the cluster nodes for use_lvmlockd and assign its value as 1

        use_lvmlockd = 1
    
  2. Set the global Pacemaker parameter no-quorum-policy to freeze:

    # pcs property set no-quorum-policy=freeze
    
  3. Rebuild initramfs on all the cluster nodes with the following steps :

    3.1 Take backup of current initramfs file on all of 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.

  4. 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 
    
  5. 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
    
  6. Set up an lvmlockd resource as part of the locking resource group:

    # pcs resource create lvmlockd --group locking ocf:heartbeat:lvmlockd op monitor interval=30s on-fail=fence
    
  7. Once the dlm and lvmlockd resources 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 is cluster_vg and LV name is cluster_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.
    
  8. 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
    
  9. Create a filesystem of your requirement (ext4/xfs) over the newly created LVM device. The mkfs command should be executed on the cluster node on which the VG is active.

  10. Create a cluster resource with resource agent ocf:heartbeat:LVM-activate so 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-vg and resource group name is HA-LVM. These values can be updated as per your requirement.
  11. Create a cluster resource with resource agent ocf:heartbeat:Filesystem so 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_lv will be mounted at /test, type of filesystem is xfs and this resource is kept in same resource group i.e. HA-LVM.
  12. 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
    
  13. The VG is now activated on node1 (rh8-nd1) and filesystem mounted on the same node. This can be validate by vgs, lvs and df commands.

  14. Configure the order constraint so to allow the controld and lvmlockd resources to get started in a cloned group called locking-clone and then the HA-LVM resource group should start:

    # pcs constraint order start locking-clone then HA-LVM
    
  15. 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
    
  16. 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:


Possible errors that could be encountered

SBR
Components
Category

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.