Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Setting up a GlusterFS Client

In our previous tutorial, we deployed a GlusterFS cluster. This tutorial will extend that by showing you how to mount your GlusterFS volume on a server for storing files.

This tutorial was created using a Debian 8 server, but the steps should also work on Ubuntu without any changes.

Steps

Install the client packages:

sudo apt install glusterfs-client

Go here to install a later version of GlusterFS from the GlusterFS repositories.

Now create a directory for mounting the GlusterFS volume.

MOUNT_PATH="$HOME/gluster-mount"
mkdir -p $MOUNT_PATH

Now mount the volume on the mount point we just created.

GLUSTER_HOST="gluster1.programster.org"
VOLUME_NAME="volume1"
MOUNT_PATH="$HOME/gluster-mount"

sudo mount -t glusterfs \
$GLUSTER_HOST:$VOLUME_NAME $MOUNT_PATH

# Give ourselves permission to create files in there.
sudo chown $USER:$USER $MOUNT_PATH

You can specify any of the hosts in your Gluster cluster for the GLUSTER_HOST, but it needs to be a hostname this server can access (which may not necessarily be any of the hostnames we used when setting up the cluster with internal networking).

You have now mounted the GlusterFS volume locally. If you use a tool like pydf you will see something like below:

Filesystem                       Size  Used Avail Use%                         Mounted on                
/dev/sda1                         19G 1375M   16G  7.2 [##...................] /                         
gluster1.programster.org:volume1  19G 1375M   16G  7.2 [##...................] /home/stuart/gluster-mount

If you are not using the same servers as in the cluster as the client, then writing files to this area will not cost you anything in local storage. Best of all, you can mount the same volume on different servers simultaneously, which can be useful for automatic failover etc.

References

Last updated: 20th June 2021
First published: 16th August 2018

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch