Tip

Mount Global File System 2, avoid corruption in RHEL High Availability

Not every type of file system resource is created equally when it comes to RHEL High Availability. Ext4 is fine, but to prevent corruption in clusters, mount Global File System 2.

You need to use a file system resource when you create an Apache Web service

Requires Free Membership to View

that is managed by a Red Hat Enterprise Linux cluster with the RHEL High Availability add-on. But which type of file system resource is the most appropriate depends on the specific environment.

Your RHEL working cluster with an Apache Web service has an Ext4 file system. For services that fail over between nodes, Ext4 is fine, but you have to be sure that two nodes don't try to write to the Ext4 file system simultaneously, as that will corrupt the file system.

If multiple nodes in the cluster need access to the same file system simultaneously, you'll need a clustered file system. In a clustered file system, the file system cache is synchronized among all the participating nodes, avoiding file system corruption. Red Hat offers the Global File System 2 (GFS2) as the default cluster file system.

Mounting Global File System 2

You need to have a running cluster to use GFS2. Install the cluster version of Logical Volume Management 2 (LVM2), and make sure the accompanying service is started on all nodes that will run the GFS2 file system. Next, create a cluster-aware LVM2 volume and create the GFS2 file system on it. Once created, you can mount the GFS2 file system from /etc/fstab on the nodes involved, or create a cluster resource that mounts it automatically.

On one of the cluster nodes, use the fdisk utility to create a partition on the storage-area network (SAN) device and make sure to mark it as partition type 0x8e. Reboot both nodes to ensure the partitions are seen on each one, and verify they are available before continuing.

On both nodes, use yum install -y lvm2-cluster gfs2-utils to install Cluster Logical Volume Management (cLVM), as well as the GFS2 software. On both nodes, use service clvmd start to start the cLVM service, and chkconfig clvmd on to enable it.

On one node, use pvcreate /dev/sdb3 to mark the LVM partition on the SAN device as a physical volume. Always verify that the name of the partition is correct.

Use vgcreate -c y clusgroup /dev/sdb3 to create a cluster-enabled volume group, then use lvcreate -l 100%FREE -n clusvol clusgroup to create a cluster-enabled volume with the name clusvol.

On both nodes, use lvs to verify that the cluster-enabled LVM volume has been created.

Use mkfs.gfs2 -p lock_dlm -t name_of_your_cluster:gfs -j 2 /dev/clusgroup/clusvol to format the clustered LVM volume as a GFS2 file system. The -p option tells mkfs to use the lock_dlm lock table. This instructs the file system to use distributed lock manager so that file locks are synchronized to all nodes in the cluster. The option -t is equally important; it specifies the name of your cluster, followed by the name of the GFS resource you want to create in the cluster. The option -j 2 tells mkfs to create two GFS2 journals; you'll need one for each node that accesses the GFS volume.

On both nodes, mount the GFS2 file system temporarily on /mnt, using mount /dev/clusgroup/clusvol /mnt. On both nodes, create some files on the file system; you'll notice that the files appear immediately on the other nodes as well.

Use mkdir /gfsvol to create a directory on which you can mount the GFS volume.

Make the mount persistent by adding a line to /etc/fstab:

/dev/clusgroup/clusvol     /gfsvol     gfs2 _netdev  0 0

Use chkconfig gfs2 to enable the GFS2 service, which is needed to mount GFS2 volumes from /etc/fstab.

Reboot both nodes to verify that the global file system is mounted automatically. At this point, GFS2 is available on all cluster nodes. When using GFS2 as the shared file system, you no longer need to set up a shared file system resource in the cluster service for RHEL. Although convenient, you don't have to use GFS2 in all scenarios. If only one node needs access to the shared file system at the same time, Ext4 is good enough.

Sander van Vugt is an independent trainer and consultant based in the Netherlands. He is an expert in Linux high availability, virtualization and performance. He has authored many books on Linux topics, including Beginning the Linux Command Line,Beginning Ubuntu LTS Server Administration and Pro Ubuntu Server Administration.

This was first published in February 2014

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.