Archival Notice
This guide was written for CentOS 7 and legacy clustered storage configurations using clvmd and Pacemaker. Please note that CentOS 7 has reached End of Life (EOL), and modern Red Hat Enterprise Linux (RHEL 8/9) releases have deprecated clvmd in favor of lvmlockd. Please refer to official vendor documentation for current high-availability deployment architectures.
When designing high-availability infrastructure for enterprise applications, sharing storage across multiple active nodes simultaneously is a common requirement. Standard filesystems like XFS or ext4 corrupt data if mounted concurrently across multiple operating systems because they lack distributed locking mechanisms.
To achieve true concurrent multi-node read and write capabilities, you need a clustered filesystem like GFS2 (Global File System 2) backed by a Distributed Lock Manager (DLM) and a cluster manager like Pacemaker.
In this guide, I will walk you through setting up an Active-Active GFS2 cluster on CentOS 7, configuring VMware STONITH fencing, enabling Clustered LVM (clvmd), and formatting shared LUNs for simultaneous mounting.
Prerequisites
You will need two CentOS 7 virtual machines (centos-vm1 and centos-vm2) with root access, connected to a shared LUN (/dev/sdc) provided by your hypervisor (e.g., VMware ESXi).
Step 1: Install Core Cluster Packages and Authentication
First, install Pacemaker, PCS (Pacemaker Configuration System), fencing agents, clustered LVM, and GFS2 utilities on both virtual machines.
yum -y install pcs pacemaker fence-agents lvm2-cluster resource-agents psmisc policycoreutils-python gfs2-utils
Set a strong password for the default cluster administration user hacluster on both nodes:
passwd hacluster
Enable and start the PCS daemon service:
systemctl enable pcsd.service
systemctl start pcsd.service
Authenticate the cluster nodes from centos-vm1 using the hacluster credentials:
pcs cluster auth centos-vm1 centos-vm2 -u hacluster
Create and start the cluster named hcluster:
pcs cluster setup --start --name hcluster centos-vm1 centos-vm2
pcs cluster enable --all
pcs status
Step 2: STONITH Fencing Configuration (VMware SOAP)
In any shared storage cluster, STONITH (Shoot The Other Node In The Head) fencing is mandatory to prevent split-brain scenarios and storage corruption. We will configure VMware SOAP fencing to power-cycle unresponsive nodes directly via ESXi.
Verify the fencing agent can communicate with your VMware hypervisor (replace IP and credentials with your environment details):
fence_vmware_soap -z --ssl-insecure -l 'root' -p 'Randompassword' -a 192.168.150.11 -o list
Create the STONITH fencing resources in Pacemaker:
# Fencing resource for Node 1
pcs stonith create vmfence1 fence_vmware_soap \
pcmk_host_map="node1:centos-vm1" \
ipaddr=192.168.150.11 \
ssl_insecure=1 \
login='root' \
passwd='Randompassword' \
pcmk_reboot_action=reboot \
delay=10
# Fencing resource for Node 2
pcs stonith create vmfence2 fence_vmware_soap \
pcmk_host_map="node2:centos-vm2" \
ipaddr=192.168.150.11 \
ssl_insecure=1 \
login='root' \
passwd='Randompassword' \
pcmk_reboot_action=reboot \
delay=10
Set location constraints so each node prefers fencing the opposite node:
pcs constraint location vmfence1 prefers centos-vm2
pcs constraint location vmfence2 prefers centos-vm1
Step 3: Clustered LVM (clvmd) and Distributed Lock Manager (dlm)
To manage LVM volume groups across both nodes simultaneously, we need to enable clustered locking in LVM and deploy DLM and CLVMD as cloned Pacemaker resources.
Enable cluster mode in LVM configuration on both nodes:
lvmconf --enable-cluster
Create the DLM and CLVMD cluster resources:
# Create DLM resource
pcs resource create dlm ocf:pacemaker:controld op monitor interval=30s on-fail=fence clone interleave=true ordered=true
# Create CLVMD resource
pcs resource create clvmd ocf:heartbeat:clvm op monitor interval=30s on-fail=fence clone interleave=true ordered=true
Enforce ordering and colocation constraints so CLVMD always starts after DLM on the same nodes:
pcs constraint order start dlm-clone then clvmd-clone
pcs constraint colocation add clvmd-clone with dlm-clone
Step 4: Active-Passive Filesystem Provisioning (Optional Baseline)
Before deploying GFS2, you can verify shared storage visibility by provisioning a standard XFS volume in Active-Passive failover mode.
Execute the following on Node 1:
# Scan physical volumes
pvs -a -o +dev_size
# Create Clustered PV and VG
pvcreate /dev/sdc
vgcreate -cy demo /dev/sdc
lvcreate -L 15G -n demolv demo
# Format as XFS
mkfs.xfs /dev/demo/demolv
Create the Pacemaker LVM and Filesystem resources to handle failover:
pcs resource create lvm-rsc LVM volgrpname=demo
pcs resource create fs_rsc Filesystem device="/dev/demo/demolv" directory="/data" fstype="xfs" options="noatime,nodiratime" op monitor interval=10s on-fail=ignore
pcs resource group add grp-data lvm-rsc fs_rsc
Step 5: Active-Active GFS2 Shared Filesystem Provisioning
To enable concurrent multi-node access, we will format the shared LUN with GFS2.
Execute the following on Node 1:
# Create Clustered PV and VG for GFS2
pvcreate /dev/sdc
vgcreate -cy gfsvg /dev/sdc
lvcreate -l 100%FREE -n gfslv gfsvg
Format the volume with GFS2. The -j 2 flag specifies 2 journals (one for each active node in the cluster). The lock table name must match your Pacemaker cluster name (hcluster):
mkfs.gfs2 -p lock_dlm -t hcluster:gfsfs -j 2 /dev/gfsvg/gfslv
Create the GFS2 filesystem resource in Pacemaker as a clone so it mounts on both nodes simultaneously:
pcs resource create gfs2_rsc Filesystem device="/dev/gfsvg/gfslv" directory="/u" fstype="gfs2" options="noatime,nodiratime" op monitor interval=10s on-fail=ignore clone interleave=true
Active-Active Storage Online
Your GFS2 clustered filesystem is now fully online! Both centos-vm1 and centos-vm2 can simultaneously read and write files to /u without data corruption or locking conflicts.