Tutorial-9122023

How to Install a Three Node GlusterFS Cluster on Debian 12

18 install parted

How to Install a Three Node GlusterFS Cluster on Debian 12

GlusterFS or Gluster File System, is a free and open-source distributed file system developed by RedHat. GlusterFS is a scalable file system formed from several servers into one entity file system that allows users to connect and mount the GlusterFS volume.

GlusterFS is a modern file system that can handle petabytes of data. Also, it’s easy to install and maintain, and also easy to scale the file system.

In the following guide, I’ll take you through the installation of GlusterFS on Debian 12 servers. We will create a high-available and replicated storage system with GlusterFS using multiple Debian servers. You will also learn how to mount GlusterFS to a Debian client machine and set up auto-mount of GlusterFS volume via /etc/fstab file.

Prerequisites

Before you proceed with this guide, confirm that you have the following:

  • Multiple Debian 12 servers – This example uses 3 Debian servers for creating the GlusterFS Cluster.
  • A non-root user with administrator privileges.
  • A Debian client machine.

Partitioning Disk with Parted

Before you get started, you will create a new partition that will be used for GlusterFS on each server. In this example, you will create a partition from disk /dev/sdb with a Parted partition manager.

Install parted to your Debian servers using the following apt command.
sudo apt install parted -y

install parted

Execute the following parted command to start partitioning the /dev/sdb disk.
sudo parted /dev/sdb

After executing the parted command, you should be in the parted environment.

Run the following command to create a new partition table for disk /dev/sdb to msdos.
mklabel msdos

Now run the command below to create a new primary partition /dev/sdb1 with format ext4 and size 5 GB.
mkpart primary ext4 1MB 5369MB

Once the partition is created, type quit to exit from Parted.

Next, run the command below to format the /dev/sdb1 partition to ext4.
sudo mkfs -t ext4 /dev/sdb1

After the /dev/sdb1 is formatted, the following output will be shown:

create partition

Now run the following command to create a new target mount directory /gluster. Then, mount the /dev/sdb1 partition to the /gluster directory.
mkdir -p /gluster
sudo mount /dev/sdb1 /gluster

Lastly, create a new directory /gluster/brick0 that will be used as the data directory for each GlusterFS server.
sudo mkdir -p /gluster/brick0

Installing GlusterFS Server

After you’ve partitioned your disk on each server, you will add the GlusterFS repository and install the glusterfs-server package to each server.

Execute the following command to 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, run the command below to 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

add repo

After adding the GlusterFS repository and GPG key, execute the following apt command to update and refresh your Debian package index.
sudo apt update

refresh repo

Then execute the apt install command below to install the glusterfs-server package.
sudo apt install glusterfs-server

Input y to proceed with the installation.

install glusterfs server

Once the glusterfs-server is installed, run the systemctl command below to start and enable the glusterd service.
sudo systemctl start glusterd
sudo systemctl enable glusterd

Lastly, verify the glusterd service to ensure that the service is running and enabled.
sudo systemctl status glusterd

The following output reveals that the glusterd service is running and enabled.

start enable glusterd

Initializing GlusterFS Cluster

With the glusterfs-server package installed, the next step is to initialize the GlusterFS Cluster. In this example, you will initialize the GLusterFS Cluster from server1, then you will add both server2 and server3 to the cluster.

From the server1 terminal, execute the gluster command below to initialize the GlusterFS Cluster with members of server2 on IP address 192.168.10.21 and server3 with IP address 192.168.10.22.
sudo gluster peer probe 192.168.10.21
sudo gluster peer probe 192.168.10.22

If the initialization is successful, the output message “peer probe: success” will be displayed.

initialize cluster

Now move to server2 or server3 and run the gluster command below to verify the GlusterFS Cluster status.
sudo gluster peer status

If everything goes well, two peers will be available on your GlusterFS Cluster.

peer status

On server2 – you should see the server1 and server3.

peer status server2

On server3, you should see the server1 and server2.

peer status server3

Lastly, you can also verify the list of available peers on your GlusterFS Cluster using the gluster command below.
sudo gluster pool list

The following output shows that the GlusterFS Cluster has three different servers.

pool list

Creating GlusterFS Volume

At this point, you’ve initialized the GlusterFS Cluster. To make the GLusterFS available for clients, you must create the volume on your GlusterFS cluster.

Execute the following command to create a new volume volume1 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

Once volume volume1 is created, start it using the gluster command below.
sudo gluster volume start volume1

The output “volume start: volume1: success” indicates that the volume1 is started.

create start volume

Now run the following command to check the list of available volumes on your GlusterFS Cluster.
sudo gluster volume info

The following output reveals that volume1 is created with type Replicate and 3 servers, such as server1, server2, and server3.

volume info

Mounting GlusterFS Volume

In the following section, you will mount the GlusterFS volume volume1 that you’ve created to a Debian Client machine. To achieve that, you must add the GlusterFS repository and install the glusterfs-client package to your Debian client machine.

Download the GPG key for the GLusterFS repository to your Debian client machine.
curl https://download.gluster.org/pub/gluster/glusterfs/11/rsa.pub | gpg --dearmor > /usr/share/keyrings/glusterfs-archive-keyring.gpg

Add the GLusterFS repository by executing the following command on your client.
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

Now refresh your Debian client repository and install the glusterfs-client package via the following apt command.
sudo apt update
sudo apt install glusterfs-client

Type y to proceed with the installation. Once the glusterfs-client is installed, you can now mount the GlusterFS volume to your Debian client machine.

install glusterfs client

Next, execute the following command to create a new target mount directory /mnt/data.
mkdir -p /mnt/data

Then, run the following command to mount the volume1 to the /mnt/data directory. You can change the GlusterFS server IP address with server1, server2, or server3.
sudo mount.glusterfs 192.168.10.20:/volume1 /mnt/data

Once volume1 is mounted, verify it using the following command.
sudo df -h

If everything goes well, you should see that volume1 is mounted to the /mnt/data directory.

mount glusterfs volume

Now that the GlusterFS volume is mounted, you will verify the write access of the target mount directory and verify the data replication from the client machine to servers on the GlusterFS Cluster.

Next, move to the /mnt/data directory and create new files using the following command. This will create multiple files in that directory and ensure that the volume is writable.
cd /mnt/data
touch file{1..15}.md

Check the list of available files using the ls command below.
ls -ah

test write

Now move to the GlusterFS servers, server1, server2, or server3, and run the ls command below to check the list of available files.
ls /gluster/brick0

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

Below data is replicated to server1.

replicated server1

Below data replicated to server2

replicated server2

Below data replicated to server3.

replicated server3

Setting Up Auto-Mount GlusterFS Volume

In the following section, you will learn how to set up auto-mount of GlusterFS volume via /etc/fstab file. This allows you to mount the GlusterFS volume automatically at boot.

Open the /etc/fstab file using the following nano editor command.
sudo nano /etc/fstab

Insert the following configuration to mount the volume1 to the target directory /mnt/data.
192.168.10.20:/volume1 /mnt/data glusterfs defaults,_netdev 0 0

Save and exit the file when finished.

Now run the following command to reload systemd manager and verify the /etc/fstab configuration. When no output message, it confirms that you’ve proper /etc/fstab configuration.
sudo systemctl daemon-reload
sudo mount -a

Conclusion

Great job! You’ve successfully installed the GlusterFS on Debian 12 servers and created the GlusterFS Cluster with 3 servers. You’ve also created and mounted a GlusterFS volume to the Debian client machine. Furthermore, you’ve also configured the auto-mount of GlusterFS volume using the /etc/fstab file.

Đăng ký liền tay Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !

Add Comment

Click here to post a comment

Đăng ký liền tay
Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !