Mount a cluster file system
The example mounts a GFS2 (Global File System 2) cluster file system. For more information about configuring cluster resources and cluster behavior during failures, see the High Availability Add-On Overview section of the Red Hat Enterprise documentation.
GFS2 (Global File System 2) is a cluster file system that provides shared access to data. It allows multiple nodes to work with the same file system simultaneously, ensuring consistency and high performance. For more information about GFS2, see the Global File System 2 section of the Red Hat Enterprise documentation.
The example uses the following for GFS2 to work:
corosync— an inter-node communication service that ensures messaging between cluster nodes, monitors their availability, and determines a quorum—the minimum number of active nodes required for the cluster to operate safely;pacemaker— a cluster resource manager that manages starting, stopping, and moving resources between cluster nodes in the event of an individual node failure;dlm— a distributed lock manager that coordinates access to shared resources within the cluster.
To mount a cluster file system:
- Connect a network volume to each server.
- Configure each cluster node.
- Mount the cluster file system.
1. Connect a network volume to each server
Use the Connect a network volume to a dedicated Linux server. guide.
2. Configure each cluster node
To ensure your nodes work together in a cluster, configure each node.
-
Connect to the server via SSH or the KVM console.
-
Open the
netplanutility configuration file with thevi:vi /etc/netplan/50-cloud-init.yaml -
On the network interface used for the
corosyncservice, add IP addresses from the private range. Servers must be able to access each other using these addresses. The iSCSI addresses used to connect network volumes andcorocyncmust not overlap.<eth_name>:addresses:- <ip_address>Specify:
<eth_name>— the name of the private network interface for the primary channel of communication between cluster nodes;<ip_address>— the private IP address of the current node in the main cluster network.
-
Exit the
vitext editor with your changes saved::wq -
Apply the configuration:
netplan apply -
Ensure that the network interfaces are configured correctly:
ip a -
Install the components for setting up the cluster environment:
apt install corosync pacemaker gfs2-utils pcs resource-agents ldmtool dlm-controld -
Restart the server.
-
Open the
/etc/hostsconfiguration file with thevi:vi /etc/hosts -
Add the IP addresses and hostnames to
/etc/hosts:<ip_address_1> <node_name_1><ip_address_2> <node_name_2>Specify:
<ip_address_1>— the primary IP address of the first node in the private network;<node_name_1>— the name of the first node in the private network, for examplenode-1;<ip_address_2>— the primary IP address of the second node in the private network;<node_name_2>— the name of the second node in the private network, for examplenode-2.
-
Exit the
vitext editor with your changes saved::wq
2. Mount the cluster file system
On one of the cluster nodes, configure the cluster and mount the cluster file system on the network volume.
-
Connect to the server via SSH or the KVM console.
-
Ensure that the network interfaces are configured correctly:
ip a -
Install the components for setting up the cluster environment:
apt install corosync pacemaker gfs2-utils pcs resource-agents ldmtool dlm-controld -
Restart the server.
-
Create a security key for
corosync:corosync-keygenThe key file will be saved in the
/etc/corosync/authkey. -
Distribute the key to the cluster nodes using the
scputility, to do this, run the command for each node:scp /etc/corosync/authkey root@<node_name>:/etc/corosync/authkeySpecify
<node_name>— the name of the node in the private network that you specified when configuring the cluster node in step 10. -
Create a cluster:
pcs cluster setup <cluster_name> <node_name_1> <node_name_2>Specify:
<cluster_name>— cluster name;<node_name_1>— the name of the current node in the private network that you specified when configuring the cluster node in step 10;<node_name_2>— the name of the second node in the private network that you specified when configuring the cluster node in step 10.
-
Start the
corosyncandpacemakerservices for all cluster nodes:pcs cluster start --all -
Ensure that the cluster status is
online:pcs status -
Ensure that the correct cluster parameters are set in the
/etc/corosync/corosync.confconfiguration file:cat /etc/corosync/corosync.confThe contents of the configuration file will appear in the response. For example:
totem {version: 2cluster_name: cluster_nametransport: knetcrypto_cipher: aes256crypto_hash: sha256}nodelist {node {ring0_addr: node-1name: node-1nodeid: 1}node {ring0_addr: node-2name: node-2nodeid: 2}}quorum {provider: corosync_votequorumtwo_node: 1}logging {to_logfile: yeslogfile: /var/log/corosync/corosync.logto_syslog: yestimestamp: on}Where:
cluster_name— cluster name, which you specified in step 7;node-1— the name of the current node in the cluster network;node-2— the name of the second node in the cluster network.
-
Output the network volume information:
multipath -llThe command output will display device information. For example:
mpatha (3600140530fab7e779fa41038a0a08f8e) dm-0 LIO-ORG,TCMU devicesize=20G features='0' hwhandler='1 alua' wp=rw|-+- policy='service-time 0' prio=10 status=active| `- 8:0:0:0 sdc 8:32 active ready running`-+- policy='service-time 0' prio=10 status=enabled`- 9:0:0:0 sdd 8:48 active ready runningHere
mpathais the network volume name. -
Format the network volume to the GFS2 file system:
mkfs.gfs2 -p lock_dlm -t <cluster_name>:<cluster_volume_name> -j <number_of_cluster_nodes> /dev/mapper/<block_storage_name>Specify:
<cluster_name>:<cluster_volume_name>— GFS2 file system identifier within the cluster, it consists of two values and in total must be no more than 16 characters, where:<cluster_name>— cluster name, which you specified in step 7;<cluster_volume_name>— file system name;
<number_of_cluster_nodes>— the number of GFS2 file system journals, one journal per each cluster node;<block_storage_name>— the name of the network volume you obtained in step 11.
-
Run
dlm— the cluster locking mechanism:pcs resource start dlm -
Configure the cluster behavior policy for when quorum is lost:
pcs property set no-quorum-policy=freeze -
Create a mount point:
mkdir -p /mnt/<mount_point_name>Specify
<mount_point_name>— the name of the directory where the cluster file system will be mounted. -
Create a resource that the cluster will mount as a GFS2 file system on all nodes at startup:
crm configure primitive <resource_name> ocf:heartbeat:Filesystem device /dev/mapper/<block_storage_name> directory /mnt/<mount_point_name> fstype gfs2Specify:
<resource_name>— a unique resource name within the cluster;<block_storage_name>— the name of the network volume you obtained in step 11;<mount_point_name>— the name of the directory on the network volume that you created in step 15.
-
Ensure that the cluster is operating correctly:
crm statusThe cluster status information will appear in the response. For example:
Cluster Summary:* Stack: corosync* Current DC: node-1 (version 2.1.2-ada5c3b36e2) - partition with quorum* Last updated: Mon Feb 10 11:58:13 2025* Last change: Fri Feb 7 19:19:07 2025 by root via cibadmin on node-1* 2 nodes configured* 2 resource instances configuredNode List:* Online: [ node-1 node-2 ]Full List of Resources:* dlm (ocf:pacemaker:controld): Started [ node-1 node-2 ]* ClusterFS (ocf:heartbeat:Filesystem): Started [ node-1 node-2 ]Where:
- the
Current DCrow displays the cluster controller node. Thepartition with quorumstatus means that the cluster has reached quorum and is operating correctly; - the
Node Listblock lists the cluster nodes. TheOnlinestatus means that the nodes are available and participating in operations; - the
Full List of Resourcesblock displays the cluster resource status. TheStartedstatus means that the resources have been successfully started on the specified cluster nodes.
- the
-
Ensure that
corosynchas established a connection with other cluster nodes:corosync-cfgtool -sThe
corosyncnetwork connection information will appear in the response. For example:Local node ID 2, transport knetLINK ID 0 udpaddr = 192.168.1.23status:nodeid: 1: connectednodeid: 2: localhostHere in the
Statusblock, the connection status to each cluster node is indicated:nodeid: 1: connected— the node is available, the connection is established;nodeid: 2: localhost— the current node.
-
Ensure that the
dlmcluster resource is working correctly and all cluster nodes are detected:dlm_tool statusThe status information for the
dlmresource will appear in the response. For example:cluster nodeid 2 quorate 1 ring seq 80 80daemon now 234888 fence_pid 0node 1 M add 630 rem 212 fail 60 fence 159 at 1 1738943226node 2 M add 61 rem 0 fail 0 fence 0 at 0 0Where:
quorate 1— the cluster has reached quorum;node 1andnode 2with statusM— the cluster nodes are active and participating in the cluster operation.
-
Ensure that the network volume is displayed in the system and mounted at the target point:
lsblkThe information about disks and their mount points will appear in the response. For example:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS----sdc 8:32 0 150G 0 disk└─mpatha 252:0 0 150G 0 mpath /mnt/gfssdd 8:48 0 150G 0 disk└─mpatha 252:0 0 150G 0 mpath /mnt/gfsWhere:
sdc,sdd— network volumes;mpatha— a multipath device;/mnt/gfs— the GFS2 file system mount point.
-
Ensure that the GFS2 file system is mounted correctly:
mount | grep gfsThe file system information will appear in the response. For example:
/dev/mapper/mpatha on /mnt/gfs type gfs2 (rw,relatime,rgrplvb)Where:
/dev/mapper/mpatha— the network volume hosting the GFS2 file system;/mnt/gfs— the file system mount point;gfs2— the file system type.