visit our site

GlusterFS – Replicate a volume over two nodes

In Technology

by Andrei Grijincu on September 25, 2017

When you are using a load balancer with two or more backend nodes(web servers) you will probably need some data to be mirrored between the two nodes. A high availability solution is offered by GlusterFS.

Within this article, I am going to show how you can set volume replication between two CentOS 7 servers.

Let’s assume this:

  • node1.domain.com – 172.31.0.201
  • node2.domain.com – 172.31.0.202

First, we edit /etc/hosts of each of the servers and append this:

We should now be able to ping between the nodes.

Installation:

Run these on both nodes:

Add priority=10 to the [epel]section in  /etc/yum.repos.d/epel.repo

Update packages and install:

Start glusterd service, also enable it to start at boot:

You can use service glusterd status and glusterfsd --version to check all is working properly.

Remember, all the installation steps should be executed on both servers!

Setup:

On node1 server run:

On node2 server run:

We need to create now the shared volume, and this can be done from any of the two servers.

This creates a shared volume named shareddata, with two replicas on node1 and node2 servers, under /shared-folder path. It will also silently create the shared-folder directory if it doesn’t exist.If there are more servers in the cluster, do adjust the replica number in the above command. The “force” parameter was needed, because we replicated in the root partition. It is not needed when creating under another partition.

Mount:

In order for the replication to work, mounting the volume is needed.  Create a mount point:

On node1 run:

On node2 run:

Testing:

On node1:

on node2:

This is how you mirror one folder between two servers. Just keep in mind, you will need to use the mount point /mnt/glusterfs in your  projects, for the replication to work.

Leave a Reply

Your email address will not be published. Required fields are marked *

+1
Share
Tweet
Share2
Stumble
Pin