How to configure HA-LVM Cluster using system_id 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 system_id 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

  • Update /etc/lvm/lvm.conf file on all the cluster nodes for system_id_source and assign its value as uname

      system_id_source = "uname"
    
  • Update /etc/lvm/lvm.conf file on all the cluster nodes for the auto_activation_volume_list so that only the volume groups that are local (not shared and not managed by pacemaker) are activated at boot time. For more information about this then see: A pacemaker managed LVM resource is active on multiple cluster nodes

vi /etc/lvm/lvm.conf 
auto_activation_volume_list  = [ "localvg" ]  
  • Rebuild initramfs on all the cluster nodes with the following steps.

    • 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
      
    • Rebuild initramfs file on both of the cluster nodes.

      # dracut -f -v
      
    • Reboot all of the cluster nodes.

  • Once all the cluster nodes are back online, 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 cluster_vg /dev/mapper/mpatha
  Volume group "cluster_vg" successfully created with system ID rh8-nd1

[rh8-nd1]# lvcreate -l 100%FREE -n cluster_lv cluster_vg
  Logical volume "cluster_lv" created.
  • Validate the newly created LVM device.
[rh8-nd1]# vgs -o+systemid
  VG              #PV  #LV  #SN   Attr        VSize      VFree      System ID
  cluster_vg       1     1    0   wz--n-    1020.00m      0         rh8-nd1  
  rhel             1     2    0   wz--n-     <11.00g      0       

[rh8-nd2]# vgs -o+systemid
  VG          #PV  #LV  #SN   Attr      VSize    VFree      System ID
  rhel         1    2     0   wz--n-   <11.00g      0             
  • If we notice the new VG is only visible on first node on which we created it i.e. rh8-nd1 and has the System ID same as hostname. While on second node, vgs command does not result in showing cluster_vg as it has rh8-nd1 as its current System ID.

  • 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.

  • Since the next steps will be configuring the cluster resource, hence validate the cluster status before proceeding.

[root@rh8-nd2 ~]# pcs status 
Cluster name: rh8-cluster
Stack: corosync
Current DC: node1 (version 2.0.0-11.el8-efbf81b659) - partition with quorum
Last updated: Wed Jan  9 23:55:44 2019
Last change: Wed Jan  9 14:25:12 2019 by root via cibadmin on node2

2 nodes configured
1 resource configured

Online: [ node1 node2 ]

Full list of resources:

 xvm	(stonith:fence_xvm):	Started node1

Daemon Status:
  corosync: active/enabled
  pacemaker: active/enabled
  pcsd: active/enabled
[root@rh8-nd2 ~]# 
  • We have all the cluster nodes marked as online and fence resource configured & tested.
  • 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 activation_mode=exclusive vg_access_mode=system_id --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.

  • 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.

  • Validate the new cluster status

# pcs status 
Cluster name: rh8-cluster
Stack: corosync
Current DC: node1 (version 2.0.0-11.el8-efbf81b659) - partition with quorum
Last updated: Thu Jan 10 00:12:36 2019
Last change: Thu Jan 10 00:12:33 2019 by root via cibadmin on node1

2 nodes configured
3 resources configured

Online: [ node1 node2 ]

Full list of resources:

 xvm	(stonith:fence_xvm):	Started node1
 Resource Group: HA-LVM
     clu-vg	(ocf::heartbeat:LVM-activate):	Started node2
     clu-fs	(ocf::heartbeat:Filesystem):	Started node2

Daemon Status:
  corosync: active/enabled
  pacemaker: active/enabled
  pcsd: active/enabled
  • The VG is now activated on node2 (rh8-nd2) and filesystem mounted on the same node. This can be validate by vgs, lvsand df commands.

  • 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 node2

# pcs status
Cluster name: rh8-cluster
Stack: corosync
Current DC: node1 (version 2.0.0-11.el8-efbf81b659) - partition with quorum
Last updated: Thu Jan 10 00:16:41 2019
Last change: Thu Jan 10 00:16:39 2019 by root via cibadmin on node1

2 nodes configured
3 resources configured

Node node2: standby
Online: [ node1 ]

Full list of resources:

 xvm	(stonith:fence_xvm):	Started node1
 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
  • It can be noticed that the resource is now started on node1 (rh8-nd1), which confirms that the VG & filesystem gets activated on passive node as well. Perform unstandby of the node.
# pcs node unstandby node2

Possible errors that could be encountered

  • If it is missed to update /etc/lvm/lvm.conf file for system_id_source before creating the VG and later enabling this parameter under lvm.conf file, then it is possible to receive an error under Failed Action of pcs status command after creating ocf::heartbeat:LVM-activate resource. The same is defined in following article with resolution.

  • 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.devices file. If you are using an LVM devices file, and use_devicesfile is enabled in lvm.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 lvmdevices is enabled, ensure that the shared devices are added to lvmdevices on passive node as well else it will result in issue as detailed in following article:

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.