‍In this comprehensive guide, we will walk you through the process of setting up GlusterFS on Rocky Linux. GlusterFS, developed by RedHat, is a scalable and open-source distributed file system that allows users to connect and mount GlusterFS volumes. With its ability to handle petabytes of data and its ease of installation and maintenance, GlusterFS is an ideal choice for businesses looking for a scalable file system solution.

Prerequisites

Before we dive into the installation process, let’s ensure that we have all the necessary prerequisites in place:

  1. Two Rocky Linux servers with an additional disk on each server.
  2. A root password configured on both servers.

Setting Up FQDN and /etc/hosts

To begin, we need to set up the Fully Qualified Domain Name (FQDN) and the /etc/hosts file on each server. This will ensure proper connectivity between the servers.

  1. Set up the FQDN on server1 by running the following command:
sudo hostnamectl set-hostname server1.localdomain.lan
  1. Set up the FQDN on server2 by running the following command:
sudo hostnamectl set-hostname server2.localdomain.lan

Next, edit the /etc/hosts file on both servers using the nano editor:

sudo nano /etc/hosts

Add the following configuration:

192.168.10.15 server1.localdomain.lan
192.168.10.20 server2.localdomain.lan

Save the file by pressing Ctrl+X and entering Y to confirm.

To test the connectivity between server1 and server2, run the following commands:

ping-c3 server1.localdomain.lan
ping-c3 server2.localdomain.lan

If the local domain names resolve to the correct IP addresses, then the connectivity is successful.

Setting Up Partitions

Before deploying GlusterFS, it is recommended to use different disk storage, especially for the production environment. In this tutorial, both server1 and server2 have a secondary disk, /dev/vdb1, with a size of 5GB.

To set up the partitions, follow these steps:

  1. Edit the /etc/fstab configuration using the nano editor:
sudo nano /etc/fstab
  1. Mount the /dev/vda1 disk to the /data/vol1 directory on server1:
/dev/vda1 /data/vol1 ext4 default 0 0
  1. Mount the /dev/vda1 disk to the /data/vol2 directory on server2:
/dev/vda1 /data/vol2 ext4 default 0 0

Next, mount the disks by running the following command:

sudo mount -a

To verify the mounted disks, use the df command:

sudo df -h

You should see the /dev/vda1 disk mounted to the /data directory.

Before installing and configuring the GlusterFS cluster, create the brick0 directory inside the /data directory:

sudo mkdir -p /data/vol1/brick0
sudo mkdir -p /data/vol2/brick0

With the partitions set up, we can proceed to the next steps of installing GlusterFS on Rocky Linux.

Adding GlusterFS Repository for Rocky Linux

Currently, Rocky Linux does not provide GlusterFS server packages. However, we can use the CentOS release GlusterFS packages instead. To add the GlusterFS repository to your Rocky Linux system, follow these steps:

  1. Install the CentOS release GlusterFS packages:
sudo dnf install centos-release-gluster9

Type y to confirm the installation and press ENTER to continue.

  1. Edit the repository configuration file CentOS-Gluster-9.repo:
 cd /etc/yum.repos.d/
 sudo nano CentOS-Gluster-9.repo

Update the baseurl line to use the Rocky Linux repository and comment out the mirrorlist line, as shown below:

# CentOS-Gluster-9.repo
## Please see http://wiki.centos.org/SpecialInterestGroup/Storage for more
# information

[centos-gluster9]
name=CentOS-$releasever - Gluster 9
#mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=$releasever&repo=storage-gluster-9
baseurl=https://dl.rockylinux.org/vault/centos/8.5.2111/storage/x86_64/gluster-9/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage

[centos-gluster9-test]
name=CentOS-$releasever - Gluster 9 Testing
baseurl=http://buildlogs.centos.org/centos/$releasever/storage/$basearch/gluster-9/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage

Save the file by pressing Ctrl+X and entering Y to confirm.

To verify the available repository on your Rocky Linux system, use the following command:

sudo dnf repolist

You should see the CentOS release repository for GlusterFS 9.

Installing GlusterFS Server

With the GlusterFS repository added, we can now install the GlusterFS packages on the Rocky Linux system. Follow these steps:

  1. Install the GlusterFS packages:
sudo dnf install glusterfs glusterfs-libs glusterfs-server

Type Y to confirm the installation and press ENTER to continue.

  1. Start the glusterfsd service and enable it to start automatically on system startup:
sudo systemctl enable glusterfsd.service
sudo systemctl start glusterfsd.service
  1. Verify the status of the glusterfsd service:
sudo systemctl status glusterfsd.service

You should see that the glusterfsd service is active with the status “exited”, indicating that it is running.

Now that the GlusterFS server is installed and running on your Rocky Linux system, we can proceed to open the necessary ports with Firewalld.

Opening Ports with Firewalld

To ensure proper communication between the GlusterFS servers, we need to open the ports for the GlusterFS service. Follow these steps to configure Firewalld:

  1. Add the glusterfs service to your Firewalld configuration and reload the firewall:
sudo firewall-cmd --add-service=glusterfs --permanent
sudo firewall-cmd --reload
  1. Verify the list of services on Firewalld:
sudo firewall-cmd --list-services

You should see the glusterfs service added to the list.

With the ports open, we can now proceed to initialize the GlusterFS cluster.

Initializing the GlusterFS Cluster

To set up the GlusterFS cluster, we will initialize and configure the servers. Follow these steps:

  1. Initialize the GlusterFS cluster on server1 and add server2 to the cluster:
sudo gluster peer probe server2.localdomain.lan

You should see the output message “peer probe: success”.

  1. Verify the peer status on server1:
sudo gluster peer status

You should see that there is one peer on server1.

  1. Check the available peers on server2:
sudo gluster peer status

You should see that there is one peer on server2.

Now that the GlusterFS cluster is initialized, we can proceed to create a GlusterFS volume.

Creating a GlusterFS Volume

To create a GlusterFS volume, follow these steps:

  1. Create a new volume named myvolume with a replication factor of 2 (using disks from server1 and server2):
sudo gluster volume create myvolume replica2 server1.localdomain.lan:/data/vol1/brick0 server2.localdomain.lan:/data/vol2/brick0

Type y to confirm and press ENTER to create the GlusterFS volume.

  1. Start the myvolume volume:
sudo gluster volume start myvolume

You should see the output message “volume start: myvolume: success”.

  1. Verify the status of the GlusterFS volume:
sudo gluster volume status

The status of myvolume should be “online” and ready to use for clients.

Optionally, you can also use the command sudo gluster volume info to see the details of the GlusterFS volume.

With the GlusterFS volume created, we can now proceed to mount it on the client machine.

Mounting the GlusterFS Volume on the Client Machine

To mount the GlusterFS volume on the client machine, follow these steps:

  1. Edit the /etc/hosts configuration on the client machine:
sudo nano/etc/hosts

Add the following configuration:

192.168.10.15 server1.localdomain.lan
192.168.10.20 server2.localdomain.lan

Save the file by pressing Ctrl+X and entering Y to confirm.

  1. Verify the connection between the client machine and the GlusterFS server:
ping -c3 server1.localdomain.lan

You should see that the client machine can connect to the GlusterFS server.

  1. Install the GlusterFS client package on the client machine:
sudo dnf install glusterfs-client

Type y to confirm the installation and press ENTER to continue.

  1. Create a new mount directory /data:
sudo mkdir /data
  1. Mount the GlusterFS volume myvolume to the /data directory:
sudo mount.glusterfs server1.localdomain.lan:/myvolume/data

If there are no errors, the GlusterFS volume is successfully mounted on the client machine.

To verify the mounted GlusterFS volume, use the df -h command:

df -h

You should see the GlusterFS volume myvolume mounted to the/data directory on the client machine.

Testing Write Access and High Availability

To test the write access and high availability of the GlusterFS volume, follow these steps:

  1. Go to the/data directory on the client machine and create new files:
cd /data
touch file1.md file2.md file3.md file4.md file5.md
  1. Move to server1 and check the/data/vol1/brick0 directory:
ls /data/vol1/brick0

You should see that the files created on the client machine are available on server1.

  1. Shut down server1:
sudo shutdown -r now
  1. Move to server2 and verify the status of GlusterFS:
sudo gluster peer status

The status of the peer server1 should be “disconnected”.

  1. Verify the available files on the /data/vol2/brick0 directory on server2:
ls /data/vol2/brick0

You should see that all the files from the client machine are also available on server2, indicating successful data replication.

Even when server1 is down, the client machine should still maintain a connection to the GlusterFS server, demonstrating the high availability of GlusterFS.

Conclusion

Congratulations! You have successfully installed and configured GlusterFS on your Rocky Linux systems. You have learned how to set up the GlusterFS cluster, create a GlusterFS volume, and mount it on a client machine. GlusterFS provides a scalable and reliable distributed file system solution, making it an ideal choice for businesses looking for efficient and secure cloud hosting.

For reliable and efficient cloud hosting solutions, consider Shape.host. Shape.host offers Linux SSD VPS hosting, providing high-performance virtual private servers tailored to your business needs. Experience the power and scalability of Shape.host’s cloud hosting services to elevate your business to new heights.