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.

server1.glusterfs.com IP Address: 192.168.56.213
Server2.glusterfs.com IP Address: 192.168.56.212
client.glusterfs.com IP Address: 192.168.56.131

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)

127.0.0.1 localhost localhost.localdomain localhost4
localhost4.localdomain4
::1 localhost localhost.localdomain localhost6
localhost6.localdomain6
192.168.56.213 server1.glusterfs.com server1
192.168.56.212 server2.glusterfs.com server2
192.168.56.131 client.glusterfs.com client

Install Repository and Import GPS Key
These following commands in step 2, we will run on all three systems.
server1.glusterfs.com/server2.glusterfs.com/client.glusterfs.com
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
below:

[epel] name=Extra Packages for Enterprise Linux 7 – $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arc
h=$basearch
failovermethod=priority
enabled=1
priority=10
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[…]

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
server2

server1.glusterfs.com/server2.glusterfs.com
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
server2.glusterfs.com to storage pool running command on
server1.glusterfs.com
server1.glusterfs.com
On server1.glusterfs.com, run below command

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

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

You should show output similar as below
Number of Peers: 1
Hostname: server2.glusterfs.com
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
server2

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
server1.glusterfs.com:/glustdata server2.glusterfs.com:/glustdata
force
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
Bricks:
Brick1: server1.glusterfs.com:/glustdata
Brick2: server2.glusterfs.com:/glustdata
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 client.glusterfs.com
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 server1.glusterfs.com:/glustvol /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
/usr/sbin/mount.glusterfs server1.glusterfs.com:/glustvol
/mnt/glustdir

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:
On client.glusterfs.com

touch /home/glustdir/test1

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

ls –l /glustdata

Leave a Reply

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