In a production environment, it is strongly recommended to use dedicated storage, such as Scaleway Block Storage, instead of system directories for GlusterFS volumes.
This ensures better data safety, scalability, and performance. Using system directories (like /glusterfs
) can lead to potential issues if the root partition fills up.
Configuring a High-Availability Storage with GlusterFS on Ubuntu
- glusterfs
- network
- filesystem
- Ubuntu
GlusterFS is an open-source, scalable network file system suited for high data-intensive workloads, such as media streaming, cloud storage, and content delivery networks (CDN). In this tutorial, we will deploy a high-availability storage solution using GlusterFS 11 and Scaleway Block Storage on Ubuntu 22.04.
Each storage Instance will mirror the other, and files will automatically be replicated across all servers.
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- An SSH key
- Three Instances running Ubuntu 22.04 LTS
- Attached Scaleway Block Storage to each GlusterFS Instance
Configuring the host file
Before installing GlusterFS, ensure each Instance can resolve the others via their hostname. This will simplify network communication between servers.
-
Log in to each Instance via SSH.
ssh root@<your_instance_public_ip> -
Update the system:
apt update && apt upgrade -y -
Edit the
/etc/hosts
file on each Instance:nano /etc/hosts -
Add entries for each Instance:
<IP_ADDRESS_1> gluster01<IP_ADDRESS_2> gluster02<IP_ADDRESS_3> client01 -
Verify hostname resolution:
ping -c 3 gluster01ping -c 3 gluster02ping -c 3 client01
Adding the GlusterFS 11 repository
-
Install the
software-properties-common
package on all Instances:apt install software-properties-common -y -
Add the GlusterFS 11 repository to all systems:
sudo add-apt-repository ppa:gluster/glusterfs-11apt update
Installing GlusterFS server
-
Install the GlusterFS server on both
gluster01
andgluster02
:apt install glusterfs-server -y -
Start the
glusterd
service and enable it at boot:systemctl start glusterd.servicesystemctl enable glusterd.service -
Verify the installation:
systemctl status glusterd.serviceglusterfs --versionYou should see GlusterFS 11.x and an active status for the service.
Setting Up a distributed GlusterFS volume with Scaleway Block Storage
Attaching Scaleway Block Storage
-
Create and attach Scaleway Block Storage to each Instance:
- From the Scaleway Console, create a new Block Storage volume for each GlusterFS server.
- Attach each volume to the respective Instance.
- Once attached, log into each Instance and check if the Block Storage is recognized:
You should see a new unmounted device (e.g.,lsblk
/dev/sdb
).
-
Partition the volume and format it with a file system (e.g.,
ext4
):mkfs.ext4 /dev/sdb -
Mount the Block Storage to a directory:
- Create a mount point for GlusterFS:
mkdir -p /mnt/glusterfs
- Mount the volume to the directory:
mount /dev/sdb /mnt/glusterfs
- Create a mount point for GlusterFS:
-
Add the Block Storage to
/etc/fstab
to ensure it mounts automatically after reboot:/dev/sdb /mnt/glusterfs ext4 defaults 0 0 -
Repeat these steps and attach, format, and mount a Block Storage volume on all GlusterFS Instances (e.g.,
gluster01
andgluster02
).
Creating a distributed GlusterFS volume
Now that Block Storage is mounted on both servers, proceed with creating the distributed GlusterFS volume:
-
Create a GlusterFS Volume using the mounted block storage directories on both servers. Run the following command on
gluster01
:gluster volume create vol01 transport tcp gluster01:/mnt/glusterfs gluster02:/mnt/glusterfs force -
Start the volume:
gluster volume start vol01 -
Check the volume status:
gluster volume info
Configuring the GlusterFS client
-
Install the GlusterFS client on
client01
:apt install glusterfs-client -y -
Create a mount point:
mkdir -p /mnt/glusterfs -
Mount the GlusterFS volume:
mount -t glusterfs gluster01:/vol01 /mnt/glusterfs -
Verify the mount:
df -h /mnt/glusterfs -
Add the volume to
/etc/fstab
for permanent mounting:gluster01:/vol01 /mnt/glusterfs glusterfs defaults,_netdev 0 0
Testing replication and mirroring
-
Mount the GlusterFS volume on both
gluster01
andgluster02
:mount -t glusterfs gluster01:/vol01 /mntmount -t glusterfs gluster02:/vol01 /mnt -
From
client01
, create test files in/mnt/glusterfs
:touch file01 file02 file03 -
Verify that the files are replicated on both
gluster01
andgluster02
:ls /mnt
You should see the same files on both servers, confirming the replication is working.