GlusterFS, a distributed file system designed by RedHat, is popular for its scalability and simplicity. This open-source software links multiple servers to form a single file system, enabling users to mount and access the GlusterFS volume. This guide will walk you through the process of installing GlusterFS on Debian 12 servers and establishing a three-node GlusterFS cluster.

Prerequisites

Before you embark on this journey, make sure you have the following:

  • A trio of Debian 12 servers
  • Administrator privileges on a non-root user
  • A Debian client machine

Disk Partitioning with Parted

You’ll start by creating a new partition on each server for GlusterFS. We’ll use the Parted partition manager to create a partition from disk /dev/sdb.

First, install parted on your Debian servers:

sudo apt install parted -y

Next, start partitioning the /dev/sdb disk:

sudo parted /dev/sdb

In the parted environment, create a new partition table for disk /dev/sdb:

mklabel msdos

Then, create a new primary partition /dev/sdb1 with format ext4 and size 5 GB:

mkpart primary ext4 1MB 5369MB

Exit from Parted:

quit

Format the /dev/sdb1 partition to ext4:

sudo mkfs -t ext4 /dev/sdb1

Create a new target mount directory /gluster and mount the /dev/sdb1 partition:

mkdir -p /gluster
sudo mount /dev/sdb1 /gluster

Finally, create a new directory /gluster/brick0 that will serve as the data directory for each GlusterFS server:

sudo mkdir -p /gluster/brick0

Installing GlusterFS Server

After partitioning your disk on each server, you need to add the GlusterFS repository and install the glusterfs-server package.

Add the GPG key of the GlusterFS repository:

curl https://download.gluster.org/pub/gluster/glusterfs/11/rsa.pub | gpg --dearmor > /usr/share/keyrings/glusterfs-archive-keyring.gpg

Then, add the GlusterFS repository to your Debian servers:

DEBID=$(grep 'VERSION_ID=' /etc/os-release | cut -d '=' -f 2 | tr -d '"')
DEBVER=$(grep 'VERSION=' /etc/os-release | grep -Eo '[a-z]+')
DEBARCH=$(dpkg --print-architecture)
echo "deb [signed-by=/usr/share/keyrings/glusterfs-archive-keyring.gpg] https://download.gluster.org/pub/gluster/glusterfs/LATEST/Debian/${DEBID}/${DEBARCH}/apt ${DEBVER} main" | sudo tee /etc/apt/sources.list.d/gluster.list

Update your Debian package index:

sudo apt update

And install the glusterfs-server package:

sudo apt install glusterfs-server

Once installed, start and enable the glusterd service:

sudo systemctl start glusterd
sudo systemctl enable glusterd

Check the glusterd service status to ensure it’s running and enabled:

sudo systemctl status glusterd

Initializing GlusterFS Cluster

With the glusterfs-server package installed, you’re ready to initialize the GlusterFS Cluster. You’ll start this process from server1, then add server2 and server3 to the cluster.

On server1, initialize the GlusterFS Cluster with server2 and server3:

sudo gluster peer probe 192.168.10.21
sudo gluster peer probe 192.168.10.22

You should see the output message “peer probe: success” if the initialization is successful.

To verify the GlusterFS Cluster status, run the following command on either server2 or server3:

sudo gluster peer status

You should see two peers available on your GlusterFS Cluster.

You can also verify the list of available peers on your GlusterFS Cluster:

sudo gluster pool list

Creating GlusterFS Volume

Now that you’ve initialized the GlusterFS Cluster, you need to create a volume to make GlusterFS available for clients.

Create a new volume with 3 replicas, server1, server2, and server3:

sudo gluster volume create volume1 replica 3 192.168.10.20:/gluster/brick0 192.168.10.21:/gluster/brick0 192.168.10.22:/gluster/brick0

Start the newly created volume:

sudo gluster volume start volume1

Check the list of available volumes on your GlusterFS Cluster:

sudo gluster volume info

Mounting GlusterFS Volume

In this section, you’ll mount the GlusterFS volume you’ve created to a Debian Client machine. To do so, you need to add the GlusterFS repository and install the glusterfs-client package on your Debian client machine.

Download the GPG key for the GlusterFS repository:

curl https://download.gluster.org/pub/gluster/glusterfs/11/rsa.pub | gpg --dearmor > /usr/share/keyrings/glusterfs-archive-keyring.gpg

Add the GlusterFS repository:

DEBID=$(grep 'VERSION_ID=' /etc/os-release | cut -d '=' -f 2 | tr -d '"')
DEBVER=$(grep 'VERSION=' /etc/os-release | grep -Eo '[a-z]+')
DEBARCH=$(dpkg --print-architecture)
echo "deb [signed-by=/usr/share/keyrings/glusterfs-archive-keyring.gpg] https://download.gluster.org/pub/gluster/glusterfs/LATEST/Debian/${DEBID}/${DEBARCH}/apt ${DEBVER} main" | sudo tee /etc/apt/sources.list.d/gluster.list

Refresh your Debian client repository and install the glusterfs-client package:

sudo apt update
sudo apt install glusterfs-client

Create a new target mount directory /mnt/data:

mkdir -p /mnt/data

Mount volume1 to the /mnt/data directory:

sudo mount.glusterfs 192.168.10.20:/volume1 /mnt/data

Verify that volume1 is mounted:

sudo df -h

Verifying Data Replication

With the GlusterFS volume mounted, you can now test the write access of the target mount directory and verify the data replication from the client machine to servers on the GlusterFS Cluster.

Move to the /mnt/data directory and create new files:

cd /mnt/data
touch file{1..15}.md

Check the list of available files:

ls -ah

On the GlusterFS servers (server1, server2, or server3), check the list of available files:

ls /gluster/brick0

If replication is working, you should see files on all GlusterFS servers created from the Debian client machine.

Auto-Mounting GlusterFS Volume

In this last section, you’ll set up the auto-mount of GlusterFS volume via /etc/fstab file, allowing the GlusterFS volume to mount automatically at boot.

Open the /etc/fstab file:

sudo nano /etc/fstab

Insert the following configuration to mount volume1 to the target directory /mnt/data:

192.168.10.20:/volume1 /mnt/data glusterfs defaults,_netdev00

Reload systemd manager and verify the /etc/fstab configuration:

sudo systemctl daemon-reload
sudo mount -a

Conclusion

Congratulations! You’ve successfully set up a GlusterFS cluster with three Debian 12 servers, created and mounted a GlusterFS volume to a Debian client machine, and configured the auto-mount of GlusterFS volume using the /etc/fstab file.

If you’re looking for a reliable hosting provider for your GlusterFS cluster, consider Shape.host. They offer high-performing SSD Linux VPS plans perfect for running a GlusterFS cluster.