How to install and configure GlusterFS on Debian 10?


In this post, I will show you how to install and configure GlusterFS on a server machine running Debian 10.

GlusterFS is a multi-scalable file system for NAS initially developed by Gluster Inc. A Gluster would allow us to connect two machines that will write simultaneously on the same disc, agreeing on the writer.

Most of the GlusterFS functionalities are implemented as translators, including:

  • Mirroring and file replication.
  • Fragmentation of the files or Data striping.
  • Load balancing for reading and writing files.
  • Fault-tolerant volumes.
  • I/O planning and disk caching.
  • The storage quotas.

So, in this post, we will use two nodes, one server, and one client.

0. What do we need?

For this tutorial, we will use two nodes. The first one will do the server functions. Here is the partition we want to replicate. The other will be the client and will contain the partition where the data will be replicated.

On Node 1 (Server):

  • Hostname: gluster1.osradar.local
  • O.S:  Debian 10
  • Memory: 1gb
  • Ip Address:
  • Disk: 8gb /dev/sda

On Node 2:

  • Hostname: gluster2.osradar.local
  • O.S:  Debian 10
  • Memory: 1gb
  • Ip Address:
  • Disk: 8gb /dev/sda

So, let us start.

1) Configure DNS on both nodes

In both nodes, it is necessary to edit the hosts file to indicate them that they will work with nodes in network communicated with an IP address and a hostname.

Open the terminal on both nodes and run the following:

:~$ su
:~# nano /etc/hosts

And add the following: gluster1.osradar.local gluster1 gluster2.osradar.local gluster2

Save the changes and exit the text editor.

2) Install GlusterFS on Debian (Both nodes)

Then install GlusterFS on both nodes. The good thing is that it’s in the official Debian repositories, so it’s pretty easy to do.

On the terminal, run the following:

:~# apt install glusterfs-server

Then, start and check the service status.

:~# systemctl start glusterd
:~# systemctl status glusterd
● glusterd.service - GlusterFS, a clustered file-system server
Loaded: loaded (/lib/systemd/system/glusterd.service; disabled; vendor preset: enabled)
Active: active (running) since Thu 2019-08-08 15:22:29 EDT; 27s ago
Docs: man:glusterd(8)
Process: 8708 ExecStart=/usr/sbin/glusterd -p /run/ --log-level $LOG_LEVEL $GLUSTERD_OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 8709 (glusterd)
Tasks: 8 (limit: 893)
Memory: 2.8M
CGroup: /system.slice/glusterd.service
└─8709 /usr/sbin/glusterd -p /run/ --log-level INFO

Aug 08 15:22:26 osradar systemd[1]: Starting GlusterFS, a clustered file-system server...
Aug 08 15:22:29 osradar systemd[1]: Started GlusterFS, a clustered file-system server.

So, GLusterFS is running.

3) Add storage on both nodes

In this post, we are assuming that both nodes have a secondary hard disk in /dev/sdb of 8Gb. However, you have to create a partition and format it with a file system.

For this, I will use fdisk and its commands to make the partition.

:~# exit
:~$ sudo fdisk /dev/sda

Write these options to create the partition.

Command (m for help): n
Select (default p): p
Partition number (1-4, default 1): 1
press enter
press enter
Command (m for help): p
Command (m for help): w

Remember replace /dev/sdb by your disk.

2.- Creating the new partition
2.- Creating the new partition

Then, format the partition. After that, create a folder and mount the partition on it.

:~$ sudo mkfs.ext4 /dev/sda1
:~$ sudo mkdir -p /data/glusterfs
:~$ sudo mount /dev/sdb1 /data/glusterfs
3.- Format the new partition
3.- Format the new partition

It is recommended to make the partition automate at the beginning of the system. So for that, add this line to fstab.


:~$ echo "/dev/sdb1 /data/glusterfs ext4 defaults 0 0" | sudo tee --append /etc/fstab

4) Creating a GlusterFS volume on Debian 10

Now it is necessary to create a new GlusterFS volume. But first, tell node 1 that node 2 is reliable. Simply put, add it to the cluster.

On node 1:

:~$ sudo gluster peer probe gluster2.osradar.local
peer probe: success.

Now check that it has been added correctly.

:~$ sudo gluster peer status
:~$ sudo gluster pool list
4.- Configuring glusterfs on Debian 10
4.- Configuring glusterfs on Debian 10

Then on both node create the folder and the volume.

:~$ sudo mkdir -p /data/glusterfs/glustervolume

On Node 1 create the volume:

:~$ sudo gluster volume create glusterfsvolume replica 2 gluster1.osradar.local:/data/glusterfs/glustervolume gluster2.osradar.local:/data/glusterfs/glustervolume
volume create: glusterfsvolume: success: please start the volume to access data

Now start the new volume:

:~$ sudo gluster volume start glusterfsvolume
volume start: glusterfsvolume: success

The configuration on the server is ready.

5) Install GlusterFS on Debian 10 (Client)

On the server-side everything is done, just do a little configuration on the client.

First, install the glusterfs package.

:~# apt install glusterfs-client

Then, create a folder to locate the GlusterFS volume data. After this, mount the volume.

:~# mkdir -p /mnt/glusterfsvolume
:~# mount -t glusterfs gluster1.osradar.local:/glusterfsvolume /mnt/glusterfsvolume

Remember open the right ports and incoming host.

It is recommended to have it automatically mounted to have immediate availability. You can do it with the following command:

:~# echo "gluster1.osradar.local:/glusterfsvolume /mnt/glusterfsvolume/ glusterfs  defaults,_netdev 0 0" | tee --append /etc/fstab

And that is it. You can start to replicate. To test it, just create some files in the volume folders and see how they replicate on the other server and on the client.

Please share this post and join our Telegram Channel.


Please enter your comment!
Please enter your name here