This article will briefly discuss how to configure a GFS2 shared filesystem across two nodes on CentOS 7. Rather than rehashing a lot of previous content, this article presumes that you have followed the steps in my previous article, in order to configure the initial cluster and storage, up to and including the configuration of the STONITH device - but no further. All other topology considerations, device paths/layouts, etc. are the same, and the cluster nodes are still centos05 and centos07. The cluster name is webcluster and the 8GB LUN is presented as /dev/disk/by-id/wwn-0x60014055f0cfae3d6254576932ddc1f7 upon which a single partition has been created: /dev/disk/by-id/wwn-0x60014055f0cfae3d6254576932ddc1f7-part1.
First, install the lvm2-cluster and gfs2-utils packages:
|
1 2 |
# yum -y install gfs2-utils # yum -y install lvm2-cluster |
Enable clustered locking for LVM, and reboot both nodes:
|
1 2 |
# lvmconf --enable-cluster # systemctl reboot |
Create clone resources for DLM and CLVMD, so that they can run on both nodes. Run pcs commands from a single node only:
|
1 2 3 4 |
# 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 \ > op monitor interval=30s on-fail=fence clone interleave=true ordered=true |
Create an ordering and a colocation constraint, so that DLM starts before CLVMD, and both resources start on the same node:
|
1 2 |
# pcs constraint order start dlm-clone then clvmd-clone # pcs constraint colocation add clvmd-clone with dlm-clone |
Check the status of the clone resources:
|
1 2 3 4 5 |
# pcs status resources Clone Set: dlm-clone [dlm] Started: [ centos05 centos07 ] Clone Set: clvmd-clone [clvmd] Started: [ centos05 centos07 ] |
Set the no-quorum-policy of the cluster to freeze so that that when quorum is lost, the remaining partition will do nothing until quorum is regained - GFS2 requires quorum to operate.
|
1 |
# pcs property set no-quorum-policy=freeze |
Create the LVM objects as required, again, from a single cluster node:
|
1 2 3 |
# pvcreate /dev/disk/by-id/scsi-360014055f0cfae3d6254576932ddc1f7-part1 # vgcreate -Ay -cy vg_data /dev/disk/by-id/scsi-360014055f0cfae3d6254576932ddc1f7-part1 # lvcreate -L 1G -n lv_test vg_data |
Create the GFS2 filesystem. The -t option should be specified as <clustername>:<fsname>, and the right number of journals should be specified (here 2 as we have two nodes accessing the filesystem):
|
1 |
# mkfs.gfs2 -p lock_dlm -t webcluster:testfs -j 2 /dev/vg_data/lv_test |
We will not use /etc/fstab to specify the mount, rather we’ll use a Pacemaker-controlled resource:
|
1 2 3 |
# pcs resource create gfs2_res Filesystem device="/dev/vg_data/lv_test" \ > directory="/mnt" fstype="gfs2" options="noatime,nodiratime" \ > op monitor interval=10s on-fail=fence clone interleave=true |
This is configured as a clone resource so it will run on both nodes at the same time. Confirm that the mount has succeeded on both nodes:
|
1 2 3 4 5 6 7 8 9 |
# pcs resource show Clone Set: dlm-clone [dlm] Started: [ centos05 centos07 ] Clone Set: clvmd-clone [clvmd] Started: [ centos05 centos07 ] Clone Set: gfs2_res-clone [gfs2_res] Started: [ centos05 centos07 ] # mount | grep gfs2 /dev/mapper/vg_data-lv_test on /mnt type gfs2 (rw,noatime,nodiratime,seclabel) |
Note the use of noatime and nodiratime which will yield a performance benefit. As per Red Hat Documentation, SELinux should be disabled too.
Next, create an ordering constraint so that the filesystem resource is started after the CLVMD resource, and a colocation constraint so that both start on the same node:
|
1 2 3 4 5 6 7 8 9 10 11 |
# pcs constraint order start clvmd-clone then gfs2_res-clone Adding clvmd-clone gfs2_res-clone (kind: Mandatory) (Options: first-action=start then-action=start) # pcs constraint colocation add gfs2_res-clone with clvmd-clone # pcs constraint show Location Constraints: Ordering Constraints: start dlm-clone then start clvmd-clone start clvmd-clone then start gfs2_res-clone Colocation Constraints: clvmd-clone with dlm-clone gfs2_res-clone with clvmd-clone |
And we’re done.
We can even grow the filesystem online:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# lvextend -L+1G /dev/vg_data/lv_test Extending logical volume lv_test to 2.00 GiB Logical volume lv_test successfully resized # gfs2_grow /dev/vg_data/lv_test FS: Mount point: /mnt FS: Device: /dev/mapper/vg_data-lv_test FS: Size: 262142 (0x3fffe) FS: Resource group size: 65517 (0xffed) DEV: Length: 524288 (0x80000) The file system grew by 1024MB. gfs2_grow complete. # df -hT /mnt Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/vg_data-lv_test gfs2 2.0G 259M 1.8G 13% /mnt |