Setup GlusterFS

A step by step guide of how to set up GlusterFS on two servers (nodes)

Note

Do all the steps on every server you have.

Configure Hosts file

We use hosts to use names instead of IP addresses.

Edit the /etc/hosts with something like this:

/etc/hosts
10.0.15.10 gfs01
10.0.15.11 gfs02

Install GlusterFS

apt install glusterfs-server

Start the service and enable it.

service glusterd start
systemctl enable glusterd

service glusterd status

Make a partition

BUT create a xfs file system. And follow this setup for this file system.

mkfs.xfs -i size=512 /dev/sda5
[...]
echo '/dev/sda5 /glusterfs xfs defaults 1 2' >> /etc/fstab

Configure the firewall

The Gluster processes on the nodes need to be able to communicate with each other. To simplify this setup, configure the firewall on each node to accept all traffic from the other node.

We will add only the interface as well, where the Glusters communicate, the interface is wg0 for example.

iptables -I INPUT -i wg0 -p all -s <ip-address> -j ACCEPT

Connect the peers

gluster peer probe gfs01

Check status:

gluster peer status

Set up a GlusterFS volume

Create a directory gv0 on the partition created for GlusterFS.

mkdir /glusterfs/gv0

Do this next two commands only on one node.

gluster volume create gv0 replica 2 gfs01:/glusterfs/gv0 gfs02:/glusterfs/gv0

If you only using 2 nodes make sure of the split brain problem

Start the volume

gluster volume start gv0

You can check if it's working on both nodes with the command:

gluster volume info

Mounting the GlusterFS Volume

If you want to use the GlusterFS volume, mount the volume to any client.

mount -t glusterfs server1:/gv0 /mnt/dStorage

List of sources

Last updated