Skip to main content

How to Set Up GlusterFS on Ubuntu

10 min read
Set up GlusterFS for me

We build a replicated GlusterFS volume across your nodes, then mount and tune it.

A complete guide to setting up a distributed, replicated GlusterFS filesystem across multiple Ubuntu 22.04 nodes, including installation, volume creation, client mounting, maintenance, and troubleshooting.

Setting Up GlusterFS on Ubuntu 22.04

GlusterFS is a scalable, distributed filesystem that ensures high availability and fault tolerance. This guide walks through configuring GlusterFS on three Ubuntu 22.04 servers, enabling a replicated filesystem across nodes. We also cover maintenance tasks, performance optimizations, and troubleshooting techniques for production-ready setups.

Overview

We will configure GlusterFS across three servers:

  • web: 10.0.0.2
  • web-node1: 10.0.0.5
  • web-node2: 10.0.0.6

By replicating data across these nodes, GlusterFS ensures fault tolerance and consistent access to data, even if a node fails.

Prerequisites

  • Three Ubuntu 22.04 servers with sudo privileges.
  • Network connectivity between the servers.
  • Update the /etc/hosts file on each server with the following entries:
10.0.0.2 web
10.0.0.5 web-node1
10.0.0.6 web-node2

Installation Steps

Step 1: Install GlusterFS on All Nodes

Run the following commands on each server:

sudo apt update
sudo apt install glusterfs-server -y
sudo systemctl start glusterd
sudo systemctl enable glusterd

Step 2: Configure the GlusterFS Trusted Pool

From the primary node (web), probe the other nodes:

sudo gluster peer probe web-node1
sudo gluster peer probe web-node2

Tip: Run gluster peer status on any node to verify that all peers are connected.

Step 3: Create Brick Directories

Create brick directories on all nodes to store GlusterFS data:

sudo mkdir -p /glusterfs/brick1/gv0

Step 4: Create and Start the Volume

On the primary node, create a replicated GlusterFS volume:

sudo gluster volume create gv0 replica 3 web:/glusterfs/brick1/gv0 web-node1:/glusterfs/brick1/gv0 web-node2:/glusterfs/brick1/gv0
sudo gluster volume start gv0

Step 5: Mount the GlusterFS Volume

Install the GlusterFS client and mount the volume on each node:

sudo apt-get install glusterfs-client -y
sudo mkdir -p /mnt/glusterfs
sudo mount -t glusterfs web:/gv0 /mnt/glusterfs

To auto-mount at boot, add the following line to /etc/fstab:

web:/gv0 /mnt/glusterfs glusterfs defaults,_netdev 0 0

Testing the Setup

Create a test file on one node to verify data replication:

sudo touch /mnt/glusterfs/testfile.txt

Check the other nodes -- the file should appear on all of them.

Adding a New Node

Step 1: Prepare the New Node

Install GlusterFS and add its IP to /etc/hosts on all servers:

10.0.0.7 web-node3

Step 2: Add the Node to the Trusted Pool

sudo gluster peer probe web-node3
sudo gluster peer status

Network Optimization

Enhance performance by tuning TCP settings:

sudo sysctl -w net.core.rmem_max=16777216
sudo sysctl -w net.core.wmem_max=16777216
sudo sysctl -w net.ipv4.tcp_rmem='4096 87380 16777216'
sudo sysctl -w net.ipv4.tcp_wmem='4096 65536 16777216'
sudo sysctl -w net.core.netdev_max_backlog=250000

GlusterFS Maintenance

Rebalancing Volumes

Rebalance the volume after adding or removing bricks:

sudo gluster volume rebalance gv0 start

Checking Volume Health

Monitor volume health and heal inconsistencies:

sudo gluster volume heal gv0 info
sudo gluster volume heal gv0

Troubleshooting

Peer Not Connected

If a peer shows as disconnected, verify:

  • Network connectivity between nodes.
  • Ports 24007-24009 are open.
  • The glusterd service is running on all nodes.
sudo systemctl status glusterd

By following this guide, we have set up a distributed and replicated GlusterFS filesystem across multiple nodes. This configuration ensures high availability and fault tolerance, making it suitable for demanding environments. We recommend regularly monitoring performance, maintaining volume health, and following best practices to ensure long-term reliability.

Frequently asked questions

How do I set up a replicated GlusterFS volume on Ubuntu 22.04?

Install glusterfs-server on each server, start glusterd, and join the other nodes from the primary one with gluster peer probe. Create a brick directory such as /glusterfs/brick1/gv0 on every node, create the volume with sudo gluster volume create gv0 replica 3 and one brick per server, and start it with sudo gluster volume start gv0. Finally, mount it on each node with the GlusterFS client.

What do I need before installing GlusterFS on Ubuntu?

A three-node replicated GlusterFS setup needs three Ubuntu 22.04 servers with sudo privileges and network connectivity between them. Add every node to /etc/hosts on each server, for example 10.0.0.2 web, 10.0.0.5 web-node1 and 10.0.0.6 web-node2, so the gluster commands can refer to nodes by name.

How do I add servers to a GlusterFS trusted pool?

From the primary node, run sudo gluster peer probe followed by each hostname, for example sudo gluster peer probe web-node1 and sudo gluster peer probe web-node2. Then run gluster peer status on any node to check that all peers are connected. The glusterd service has to be installed, started and enabled on every node first.

How do I mount a GlusterFS volume automatically at boot?

Add the line web:/gv0 /mnt/glusterfs glusterfs defaults,_netdev 0 0 to /etc/fstab on each node. Before that, install the client with sudo apt-get install glusterfs-client -y, create the mount point with sudo mkdir -p /mnt/glusterfs, and test a manual mount with sudo mount -t glusterfs web:/gv0 /mnt/glusterfs.

How can I test that GlusterFS replication works?

Create a file on the mounted volume of one node, for example with sudo touch /mnt/glusterfs/testfile.txt, then check the same path on the other nodes. On a working replicated volume, the file appears on all of them. Replication across nodes is what keeps the data available if one node fails.

How do I add a new node to an existing GlusterFS cluster?

Install GlusterFS on the new server and add its address to /etc/hosts on all servers, for example 10.0.0.7 web-node3. Then run sudo gluster peer probe web-node3 and confirm with sudo gluster peer status. After adding or removing bricks, rebalance the volume with sudo gluster volume rebalance gv0 start.

Why does a GlusterFS peer show as disconnected?

Check three things when a GlusterFS peer shows as disconnected. There must be network connectivity between the nodes, ports 24007-24009 must be open, and the glusterd service must be running on all nodes. Check the service with sudo systemctl status glusterd.

How do I check GlusterFS volume health?

Run sudo gluster volume heal gv0 info to see the heal status of the volume, and sudo gluster volume heal gv0 to heal any inconsistencies it finds. Regular checks of volume health and performance are part of keeping a replicated GlusterFS setup reliable over time.

Read how we handle it in Cloud & Server Management.

Related Articles

Server & DevOps

How to Tune a Linux Server That Falls Over Only at Peak

Load average under one, CPU half idle, and for four minutes every evening the site returns errors. The limits that bite at peak are queues and counters rather than utilisation, which is why no dashboard you own is measuring them. This guide shows where to read the accept queue overflow counter, the PHP-FPM log lines that name the pool ceiling in plain words, the ephemeral port range, and the connection tracking table, along with the sysctl and nginx directives that raise each one. Every observation command comes before the change it justifies.

Server & DevOps

How to Restore One Table From a Full Cluster Backup

Somebody emptied one table and the rest of the database is still taking orders. Restoring the whole backup over production would throw away every write since the dump, to fix damage that lives in a single table. This is the side restore instead, with the format choice that decides whether selective restore is even possible, the pg_restore flags that behave differently from the pg_dump ones you know, and the foreign keys and sequences that turn a successful restore into a broken application an hour later.

Server & DevOps

Your Images Are Probably Not What Makes LCP Slow

Cloudflare's BEACON data from 10,000 large sites shows where slow LCP comes from. On pages rated poor, downloading the LCP resource took 119 ms, while the first byte, late discovery and blocked rendering each took one and a half to two seconds.