GlusterFS Installation on CentOS 7

GlusterFS is an open source server that realizes a distributed file system
and it’s developed by Gluster Inc., acquired by Redhat in September
2011. Using GlusterFS we can aggregate multiple servers and can use as
one file system.
This tutorial will show you how to setup GlusterFS with high availability
storage on two storage servers that usages GlusterFS. Each server will
be mirrored and replicate the data automatically across both storage
servers in real-time. It aggregates all storage bricks over Remote direct
memory access. And another one will be used as a client.

  • Preparatory Note

I am going to use three systems in this tutorial, two systems will act as
server and one system will act as an client. IP Address: IP Address: IP Address:

All these servers should be able to communicate with each other, either
we can configure DNS or we can do local host entry. In this tutorial I
have done the entry in hosts file on all three systems as below:
(Note: In this setup you can also directly use IP address, If you want to
directly use IP address then you don’t need to setup any DNS or hosts
entry. You can skip this hosts entry then, but if you want to resolve
hostname then you have to make this entry so that each hostnames
can communicate with each other) localhost localhost.localdomain localhost4
::1 localhost localhost.localdomain localhost6
localhost6.localdomain6 server1 server2 client

Install Repository and Import GPS Key
These following commands in step 2, we will run on all three systems.
Import the GPG key for packages we will need following command
as below.

rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY*
Now we need to install EPEL open source repository version 7
using command as below.

yum –y install epel-release
Then install yum priorities to update priorities
yum –y install yum-priorities

Now we have to update priorities from repository in the epel
section so that we can install relevant versions of glusterFS.
Update priority=10 from /etc/yum.repos.d/epel.repo as showing

[epel] name=Extra Packages for Enterprise Linux 7 – $basearch

Now update the repository using yum command as below

yum –y update

Install and Configure GlusterFS Servers
These commands in step 3 we will use on only two systems server1 and
Before installing glusterFS we have to install centos repository as glusterfs
package is available in centos repository

yum –y install centos-release-gluster

Once the centos group repository gets installed using the above command, now
you can install glusterfs server using the following command.

yum –y install glusterfs-server

Now we have to start the service and also need to enable service so that gluster
server can be started automatically after system boot.

systemctl enable glusterd.service

You can check version of glusterFS using below command

glusterfsd –version

If you have firewalld activated on your server, then make sure that all
below ports are allowed from there.

111, 24007, 24008, 24009 + all bricks should be allowed

Or you can stop and disable that service using the command below.

systemctl stop firewalld

Now we will work on server1 and will create peers, we will add to storage pool running command on
On, run below command

gluster peer probe
You should get output as below
peer probe: success.

Now in the status of storage pool information should be shown on, to check status of trusted storage pool, you can
run below command.

You should show output similar as below
Number of Peers: 1
Uuid: 681e20db-ab1a-30c8-109c-314c86f47fe5
State: Peer in Cluster (Connected)

Now we will create a volume using name glustvol with 2 replicas (We
are using 2 replicas here because we have two storage servers in this
tutorial, replica should be equal to number of storage servers we are
using) on server1 and server2 for /glustdata folder (We have to create
this directory)
You can create directory using below command on both server1 and

mkdir /glustdata

Once the directory is created you can use the command below to
create volume for /glustdata with server1 and server2.

Gluster volume create glustvol replica 2 transport tcp
You should get output as below
volume create: glustvol: success: please start the volume to access data

Now start the volume using command:

gluster volume start glustvol
Output should be as below
Volume start: glustvol: success

Now check the volume information using below command

Gluster volume info
Output should be similar as below
Volume Name: glustvol
Type: Replicate
Volume ID: c2d926ba-e8c9-3beb-c7b5-e61d5ba01386
Status: started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Option Reconfigured:
Performance.reddir-ahead: on

Configure the GlusterFS Client
Now we will install and configure GlusterFS client on client machine,
now we will run all commands written in step 4 on
Install glusterfs-client using the command below.

yum –y install glusterfs-client

Now we will create a directory on client machine using below command

mkdir /home/glustdir

Now we are almost done, we have to only mount that volume
“glustvol” on the client machine which we created as a trusted storage
pool on server1 to /home/glustdir.
We can use the command below to mount the same.

mount.glusterfs /home/glustdir

The above command is only use to mount for temporary, if you want to
mount for permanent, then we have to update entry in “/etc/rc.local”
as below

vim /etc/rc.local
Then do the entry as showing below

Then reboot the server using “reboot” command
Once the mount process is completed, we will go to Testing process.

5 Testing
Now let’s create some test files under /home/glustdir on client machine
as below:

touch /home/glustdir/test1

Now let’s check glustdata directory on and, these files should be available there, you can list
the directory using the command below.

ls –l /glustdata

Leave a Reply

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