The Complete GlusterFS Installation Guide: Step-by-Step

Learn how to easily set up and configure a highly available GlusterFS storage cluster from scratch using this simple, modern, step-by-step tutorial.

glusterfs

Introduction to Distributed Storage

Linux

What is GlusterFS?

GlusterFS is a powerful, free, and open-source file system that lets you connect the storage from many different computers into one large, shared pool of storage. Imagine you have three separate computers, each with its own hard drive. GlusterFS acts like a layer of glue that binds these separate hard drives together, so they appear and work to the user as a single, giant hard drive. This makes it very easy to store huge amounts of data without needing to buy expensive, specialized storage machines.

One of the best things about GlusterFS is how it keeps your data safe and always available. When you save a file to this shared pool, GlusterFS can automatically copy it across multiple computers in the background. This means if one computer crashes or its hard drive completely breaks, your data is still perfectly safe and accessible from the other computers. You can also easily add more storage at any time just by plugging in a new computer and adding it to the group, which is known as a "cluster."

Because it is so flexible and reliable, many companies use GlusterFS for things like cloud computing, storing large backup files, and keeping media files like videos and images safe. It does not require any special hardware to run; it works beautifully on standard, everyday servers using regular network cables. This makes it a popular choice for anyone who needs a highly scalable and safe way to manage a rapidly growing amount of digital information.

Prerequisites

  • Three separate servers: Virtual machines or physical computers running a modern Linux operating system (like CentOS Stream, RHEL, or Fedora) named server1 , server2 , and server3 .
  • A dedicated storage disk: At least one secondary, empty hard drive on each server dedicated entirely to GlusterFS storage. For this guide, we will use the raw, unpartitioned device /dev/sdb .
  • Network connectivity: A working network connection with static IP addresses that allows all three servers to communicate with each other over the local network.
  • Root privileges: Root or sudo access on all servers to install software packages and modify system files.
  • Time synchronization: NTP (Network Time Protocol) must be installed and running on each server to ensure they all share the exact same system time.

Step-by-Step Installation

1

Configure Hostname Resolution

Run on all three servers
Before the servers can connect using names like server1, they need to know what IP addresses belong to those names. If you do not have an internal DNS server, you must manually map the IP addresses to hostnames in the /etc/hosts file.
BASH
# Open the hosts file using a text editor like nano or vi
nano /etc/hosts

# Add the IP addresses and hostnames for all three nodes at the bottom of the file
192.168.1.101 server1
192.168.1.102 server2
192.168.1.103 server3
2

Format and Mount the Storage Bricks

Run on all three servers
First, we need to prepare the secondary hard drive (/dev/sdb) on each server. GlusterFS calls these storage locations "bricks". We will format the raw disk directly with the XFS file system and mount it. We use 0 0 in the fstab entry to prevent boot hangs if the drive fails, as XFS ignores standard fsck passes anyway.
BASH
# Format the raw disk directly with the XFS file system
mkfs.xfs -i size=512 /dev/sdb

# Create the folder where the drive will be mounted
mkdir -p /data/brick1

# Add this rule so the drive mounts automatically if the server restarts
echo '/dev/sdb /data/brick1 xfs defaults 0 0' >> /etc/fstab

# Mount the drive and check if it was successful
mount -a && mount
3

Install the GlusterFS Software

Run on all three servers
Standard Linux repositories do not include GlusterFS by default. We must first add the Gluster repository, then install the software, and finally enable it to start automatically upon server reboot using systemctl.
BASH
# Install the GlusterFS repository release package
yum install centos-release-gluster -y

# Install the GlusterFS server package
yum install glusterfs-server -y

# Enable and start the GlusterFS service automatically
systemctl enable --now glusterd

# Check to make sure it is running (Look for "Active: active")
systemctl status glusterd
4

Configure the Firewalls

Run on all three servers
The servers need to talk to each other without the firewall blocking them. We will use firewalld to permanently allow traffic from the other servers. Replace <ip-address> with the actual IP addresses of the other two nodes in your cluster.
Bash
# Run this for the first peer's IP address
firewall-cmd --zone=trusted --add-source=<ip-address-1> --permanent

# Run this for the second peer's IP address
firewall-cmd --zone=trusted --add-source=<ip-address-2> --permanent

# Reload the firewall to apply the changes immediately
firewall-cmd --reload
5

Connect the Servers Together

Run from server1 ONLY
Now we will link the servers together into a "trusted pool". Once server1 successfully invites the other servers, the pool is fully established and synchronized across all nodes. Because we configured /etc/hosts in Step 1, these commands will resolve correctly.
From server1, invite the other two servers:
BASH
gluster peer probe server2
gluster peer probe server3
Check if they are connected (Run from server1):
BASH
gluster peer status
(You should see a message indicating both peers are in the state: Peer in Cluster (Connected)).
6

Create the Shared Storage Volume

Run folder creation on all servers, run volume creation on ONE server
We will now create a single volume named gv0 that keeps 3 copies of every file (one on each server) for maximum safety. It is crucial to create a subdirectory inside the mount point rather than using the root of the drive.
First, on ALL three servers, create a folder inside the brick:
BASH
mkdir -p /data/brick1/gv0
Next, from ANY ONE server (like server1), build and turn on the volume:
BASH
# Create the highly available shared volume
gluster volume create gv0 replica 3 server1:/data/brick1/gv0 server2:/data/brick1/gv0 server3:/data/brick1/gv0

# Start the volume
gluster volume start gv0

# Check that the volume status says "Started"
gluster volume info
7

Test Your New Storage Pool

Run on any server
Let's test the cluster by pretending one of the servers is a user (client), saving files to it, and making sure the files replicate perfectly across the cluster.
BASH
# Create a test folder on the server
mkdir /mnt/gluster-test

# Mount the GlusterFS shared pool to that folder
mount -t glusterfs server1:/gv0 /mnt/gluster-test

# Copy 100 system log files into the shared pool to test replication
for i in `seq -w 1 100`; do cp -rp /var/log/messages /mnt/gluster-test/copy-test-$i; done
Verify the test worked:
BASH
# Check the client view (It should output 100)
ls -lA /mnt/gluster-test/copy* | wc -l

# Check the actual physical hard drive on ANY of the three servers (It should also output 100 on each one)
ls -lA /data/brick1/gv0/copy*

Discover CTCservers Dedicated Server Locations

CTCservers servers are available around the world, providing diverse options for hosting websites. Each region offers unique advantages, making it easier to choose a location that best suits your specific hosting needs.