# Tutorial: Deploy a Highly Availability GlusterFS Storage Cluster

Link: [https://thenewstack.io/tutorial-deploy-a-highly-availability-glusterfs-storage-cluster/](https://thenewstack.io/tutorial-deploy-a-highly-availability-glusterfs-storage-cluster/)

<div id="bkmrk-the-glusterfs-networ" style="text-align: justify;"><div id="bkmrk-the-glusterfs-networ-1"><div class="post-excerpt">The GlusterFS network file system is perfectly suited for various use cases that require the handling of large amounts (think petabytes) of stored data.</div></div><div id="bkmrk-nov-6th%2C-2020-10%3A32a"><span class="date">Nov 6th, 2020 10:32am by </span><span class="author">[Jack Wallen](https://thenewstack.io/author/jack-wallen/ "Posts by Jack Wallen")</span></div></div><div id="bkmrk-" style="text-align: justify;">![Featued image for: Tutorial: Deploy a Highly Availability GlusterFS Storage Cluster](https://cdn.thenewstack.io/media/2020/11/c319d1fe-maksym-kaharlytskyi-q9y3lruuxmg-unsplash.jpg)</div>The [GlusterFS](https://www.gluster.org/) network file system is perfectly suited for various use cases that require the handling of large amounts (think petabytes) of stored data. In other words, this could be the ideal [storage system for your various cloud or container deployments](https://thenewstack.io/storage/). With features like sharding, tiering, AFR Statistics, file snapshots, distributed hash tables, nonuniform file access, OVirt and QEMU integration, RDMA connection manager, rebalance, server quorum, distributed geo-replication, and brick failure detection, this file system might be ideal for your needs. Red Hat currently manages this open source network file system.

Of course, how you use GlusterFS with your cloud implementation will depend on which cloud platform you are using. But before you can roll it into your system, you first must get this networkable storage up and running.

I’m going to walk you through the process of deploying a three-node GlusterFS cluster on Ubuntu Server 20.04. To make this work you’ll need three instances of Ubuntu. For my purposes those will have the following hostnames and IP addresses:

`192.168.1.24 gluster1`

`192.168.1.25 gluster2`

`192.168.1.26 gluster3`

You will want to change the IP addresses to match your network topography.

<div id="bkmrk-trending-stories-the" style="text-align: justify;"><div class="row"><div class="copy-column"><div><div class="tns-trending-stories-block inline" data-context="inline"><div class="section-heading">TRENDING STORIES</div><div class="tns-trending-stories-list tns-trending-stories-list-inline tns-trending-stories-list-668a2d2ed2d2a" data-context="inline" data-uuid="668a2d2ed2d2a">1. [The Architect’s Guide to Storage for AI](https://thenewstack.io/the-architects-guide-to-storage-for-ai/)
2. [The Architect’s Guide: A Modern Data Lake Reference Architecture](https://thenewstack.io/the-architects-guide-a-modern-data-lake-reference-architecture/)
3. [How to Work with Containers in TrueNAS](https://thenewstack.io/how-to-work-with-containers-in-truenas/)
4. [How to Create an Object Storage Bucket with MinIO Object Storage](https://thenewstack.io/how-to-create-an-object-storage-bucket-with-minio-object-storage/)
5. [Enable End-to-End Encryption Between Nextcloud and Your Desktop Client](https://thenewstack.io/enable-end-to-end-encryption-between-nextcloud-and-your-desktop-client/)

</div></div></div></div></div></div>## First Steps

After spinning up your instances of Ubuntu, the first thing you want to do is update and upgrade each. You can do that (on all three) with the following two commands:

`sudo apt-get update`

`sudo apt-get upgrade -y`

If the kernel gets upgraded in any of these instances, you’ll want to make sure to reboot the server (so the updates get applied).

After you’ve upgraded, you’ll then want to set the hostname for each. This can be done with a handy command like so:

`sudo hostnamectl set-hostname NAME`

Where NAME will be gluster1, gluster2, and gluster3.

Next, we need to map the addresses in the /etc/hosts file. Open that file (on each server) for editing with the command:

`sudo nano /etc/hosts`

Map those addresses by adding the following at the bottom of the file:

<div id="bkmrk-1-2-3-192.168.1.24-g" style="text-align: justify;"><div class="row"><div class="copy-column"><div><div class="crayon-syntax crayon-theme-github-gist crayon-font-liberation-mono crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-always" id="bkmrk-1-2-3-192.168.1.24-g-1"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" wrap="soft"></textarea>  
</div><div class="crayon-main"><table class="crayon-table"><tbody><tr class="crayon-row"><td class="crayon-nums " data-settings="show"><div class="crayon-nums-content"><div class="crayon-num" data-line="crayon-668a2d2eb2863341150524-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-668a2d2eb2863341150524-2">2</div><div class="crayon-num" data-line="crayon-668a2d2eb2863341150524-3">3</div></div></td><td class="crayon-code"><div class="crayon-pre"><div class="crayon-line" id="bkmrk-192.168.1.24-gluster-1"><span class="crayon-cn">192.168.1.24</span> <span class="crayon-i">gluster1</span></div><div class="crayon-line crayon-striped-line" id="bkmrk-192.168.1.25-gluster-1"><span class="crayon-cn">192.168.1.25</span> <span class="crayon-i">gluster2</span></div><div class="crayon-line" id="bkmrk-192.168.1.26-gluster-1"><span class="crayon-cn">192.168.1.26</span> <span class="crayon-v">gluster3</span></div></div></td></tr></tbody></table>

</div></div></div></div></div></div>  
Save and close the file.

## Installing GlusterFS

With the release of Ubuntu Server 20.04, GlusterFS is now found in the standard repositories. So to install the software, go back to the terminal window and issue the command:

`sudo apt-get install glusterfs-server -y`

Make sure to install GlusterFS on gluster1 and gluster2.

After the installation completes, start and enable GlusterFS on each server with the following two commands:

`sudo systemctl start glusterd`

`sudo systemctl enable glusterd`

## Configuring GlusterFS

Now that your servers are ready and GlusterFS is installed, it’s time to configure gluster. On gluster1, create a trusted pool with the command:

`sudo gluster peer probe gluster2`

You should see peer probe: success returned.

Verify the status of the two peers with the command:

`sudo gluster peer status`

You should see that gluster2 is connected (Figure 1).

<div id="bkmrk-%C2%A0-%C2%A0zoom-figure-1%3A-ou" style="text-align: justify;"><div class="row"><div class="copy-column"><div><div><dl id="bkmrk-%C2%A0-%C2%A0zoom-figure-1%3A-ou-1"><dt><div class="wp-caption aligncenter">[![Figure 1: Our gluster1 and gluster2 servers are connected.](https://cdn.thenewstack.io/media/2020/11/8d694473-gluster1.jpg)<div class="pswp-zoom-icon"><svg clip-rule="evenodd" fill-rule="evenodd" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M15.853 16.56c-1.683 1.517-3.911 2.44-6.353 2.44-5.243 0-9.5-4.257-9.5-9.5s4.257-9.5 9.5-9.5 9.5 4.257 9.5 9.5c0 2.442-.923 4.67-2.44 6.353l7.44 7.44-.707.707-7.44-7.44zm-6.353-15.56c4.691 0 8.5 3.809 8.5 8.5s-3.809 8.5-8.5 8.5-8.5-3.809-8.5-8.5 3.809-8.5 8.5-8.5zm-4.5 8h4v-4h1v4h4v1h-4v4h-1v-4h-4v-1z"></path></svg> Zoom</div>](https://cdn.thenewstack.io/media/2020/11/8d694473-gluster1.jpg)</div>Figure 1: Our gluster1 and gluster2 servers are connected.

</dt><dd></dd></dl></div></div></div></div></div>## Creating a Distributed Volume

We’ll next create a distributed volume. I would highly recommend you create this volume on a partition that isn’t within the system directory (aka, not on the same drive that your OS is hosted on). If you create this volume on the same drive as the OS, you could run into sync errors.

Let’s create a new directory for GlusterFS (on both gluster1 and gluster2) with the command:

`sudo mkdir -p /glusterfs/distributed`

With the directory created, we can now create the volume (named v01) that will replicate on both gluster1 and gluster2. The command for this is:

`sudo gluster volume create v01 replica 2 transport tcp gluster1:/glusterfs/distributed gluster2:/glusterfs/distributed`

You will be prompted to okay the creation. Type “y” to allow the creation of the new distributed volume. Once that succeeds, start the volume with the command:

`sudo gluster volume start v01`

You can verify the creation with the command:

`sudo gluster volume info v01`

## Installing the GlusterFS Client and Connecting to the Distributed Volume

It’s now time to install the GlusterFS client. We’ll do this on gluster3. For this, issue the command:

`sudo apt install glusterfs-client -y`

Create a new mount point for GlusterFS on gluster3 with the command:

`sudo mkdir -p /mnt/glusterfs`

We can now mount the distributed file system with the command:

`sudo mount -t glusterfs gluster1:/v01 /mnt/glusterfs/`

Finally, you’ll want to make sure the distributed file system is mounted at boot. To do this, you’ll need to edit the fstab file with the command:

`sudo nano /etc/fstab`

At the bottom of that file, add the following:

`gluster1:/v01 /mnt/glusterfs glusterfs defaults,_netdev 0 0`

## Testing the Filesystem

With all of this in place, we can now test the GlusterFS distributed file system. On gluster1 issue the command:

`sudo mount -t glusterfs gluster1:/v01 /mnt`

On gluster2 issue the command:

`sudo mount -t glusterfs gluster2:/v01 /mnt`

Move over to gluster3 and create a test file with the command:

`sudo touch /mnt/glusterfs/thenewstack`

Check to make sure the new file appears on both gluster1 and gluster2 with the command (run on gluster1 and gluster2):

`ls /mnt`

You should see thenewstack appear in both directories on gluster1 and gluster2 (Figure 2).

<div id="bkmrk-%C2%A0-%C2%A0zoom-figure-2%3A-th" style="text-align: justify;"><div class="row"><div class="copy-column"><div><div><dl id="bkmrk-%C2%A0-%C2%A0zoom-figure-2%3A-th-1"><dt><div class="wp-caption aligncenter">[![](https://cdn.thenewstack.io/media/2020/11/576b4cdf-gluster2.jpg)<div class="pswp-zoom-icon"><svg clip-rule="evenodd" fill-rule="evenodd" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M15.853 16.56c-1.683 1.517-3.911 2.44-6.353 2.44-5.243 0-9.5-4.257-9.5-9.5s4.257-9.5 9.5-9.5 9.5 4.257 9.5 9.5c0 2.442-.923 4.67-2.44 6.353l7.44 7.44-.707.707-7.44-7.44zm-6.353-15.56c4.691 0 8.5 3.809 8.5 8.5s-3.809 8.5-8.5 8.5-8.5-3.809-8.5-8.5 3.809-8.5 8.5-8.5zm-4.5 8h4v-4h1v4h4v1h-4v4h-1v-4h-4v-1z"></path></svg> Zoom</div>](https://cdn.thenewstack.io/media/2020/11/576b4cdf-gluster2.jpg)</div>Figure 2: The test file has appeared on gluster1.

</dt><dd></dd></dl></div></div></div></div></div>And there you go, you now have a GlusterFS distributed file system up and running. You should now be able to integrate this into anything that requires a high-volume file system that offers plenty of features that can satisfy many of your cloud and container needs.

### More Storage Tutorials

[Tutorial: Set up Cloud Storage on a Linux Server, Using Seafile](https://thenewstack.io/tutorial-set-up-cloud-storage-on-a-linux-server-using-seafile/)

[Tutorial: Create a Docker Swarm with Persistent Storage Using GlusterFS](https://thenewstack.io/tutorial-create-a-docker-swarm-with-persistent-storage-using-glusterfs/)

[Tutorial: Dynamic Provisioning of Persistent Storage in Kubernetes with MiniKube](https://thenewstack.io/tutorial-dynamic-provisioning-of-persistent-storage-in-kubernetes-with-minikube/)