Set up Geo-replication

Ayush Ujjwal
Geek Culture
Published in
4 min readApr 27, 2021


Geo-replication image

In the last blog, we went through the basics of Geo-replication and its different deployment services. In this blog, we will be going through the setup step-by-step. 🚶


You have at least 2 Virtual Machines (VMs). One of them will hold the main volume 💾 and the other one will hold the secondary volume 💾. We will be setting up geo-replication on these two volumes only.

Let’s start with the setup now 😄


  1. Create 2 volumes. If you want to know how to set up volumes refer to this article

This is with replica volume. With just 2 servers you can go for 2 distribute volumes with 1 server each. You can refer to the following doc.

2. Start 🚲 the 2 volumes. Here, I am considering the 2 volumes as geom(main volume) and geos(secondary volume)

# gluster vol start geom
# gluster vol start geos

The following 2 commands must give a success else the volumes won’t be started.

3. If your primary cluster:

  • has a minimum of 2 nodes then execute the following command and go to step 8 directly
# gluster vol set all cluster.enable-shared-storage enable
  • has one node in the cluster follow from step 4.

4. You need to create a shared storage volume on the primary or main server. (You can replace the hostname with the IP address)

# gluster vol create gluster_shared_storage replica 3 servera:/data/glusterfs/avol/brick1/b11 servera:/data/glusterfs/avol/brick1/b12 servera:/data/glusterfs/avol/brick1/b13 force

Why force? 😈

This is because it will give a warning 😷 as you are trying to create a replica volume using three bricks on the same server and hence fail. If you don’t want that to happen force is necessary to be added in the end.

5. Start 🚲 the shared volume that you created now

# gluster vol start gluster_shared_storage

6. Now you need to create a shared storage directory. 💾 This will be used as a mount point for the shared storage.

# mkdir -p /var/run/gluster/shared_storage

With the help of mkdir -p command you can create sub-directories of a directory. It will create parent directory first, if it doesn’t exist. But if it already exists, then it will not print an error message and will move further to create sub-directories.

7. Mount the shared volume 💾 on the directory just created.

# mount -t glusterfs servera:gluster_shared_storage /var/run/gluster/shared_storage

When you ‘mount’ something you are placing access to the file system contained within onto your root file system structure. Effectively giving the files a location.

To know more about mount refer to this.

8. Passwordless-ssh setup:

On any one of the primary servers generate the ssh-key 🔑

# ssh-keygen

Copy the ssh-key to any one of the secondary servers

# ssh-copy-id root@serverb    

You can replace the hostname with the IP address.

9. Create ssh keys

# gluster system:: execute gsec_create 

This command does the following:

  • It created 2 pairs of ssh keys (private and public), one for ‘tar over ssg’ and the other for ‘gsyncd shell’ on each node in the cluster.
  • It prefixes the ssh public keys with the command=“tar ${SSH_ORIGINAL_COMMAND#*}” and ‘command=“/usr/libexec/glusterfs/gsyncd”’ for ‘tar’ and gsyncd ssh public keys respectively.
  • It aggregates above prefixed ssh public keys from all the nodes of the cluster into single file located at “/var/lib/glusterd/geo-replication/”

10. Create the session and push the ssh keys to all the secondary cluster nodes.

# gluster vol geo-rep geom serverb::geos create push-pem

11. You need to enable the use of gluster_shared_storage for geo-rep. Although this step can be ignored if the main volume is not a replicated volume/ EC volume.

# gluster vol geo-rep geom serverb::geos config use_meta_volume true

Geo-rep uses the shared storage volume to decide which worker has to be ACTIVE. It creates common files per replica and workers acquire fcntl lock on it, whoever wins will become ACTIVE.

12. Check the status of geo-rep by executing the following command.

# gluster vol geo-rep geom serverb::geos status

You will get a table with the status of the geo-rep workers. It should show Created.

13. You need to start geo-rep and check the status again.

# gluster vol geo-rep geom serverb::geos start
# gluster vol geo-rep geom serverb::geos status

The status of all the geo-rep workers should go to Initializing and then to History Crawl on to Changelog Crawl.

And DONE 😃🎊


Also, Read