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

Author

Programster

Stuart is a software developer with a passion for Linux and open source projects.

comments powered by Disqus
We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites. More info.