GlusterFS – Real Time Data Replication Across Multiple CentOS Nodes

GlusterFS ?

GlusterFS is an open source  network / cluster filesystem and based on a stackable user space design.In this tutorials we will achieve high availability of storage(i.e real time replication of files) across two linux machines using GlusterFS.  Although glusterfs found its application in different areas like cloud computing, streaming media services, and content delivery networks. In this tutorials we will use the term brick  (It is the storage filesystem that has been assigned to a volume).

In Our case , we are using two Centos 6.2 Machines and Using glusterfs static files of Apache document root (/var/www/html)  will be replicated across these machine.  Follow the below steps to achieve this…

Step:1 Enable EPEL Repository on both the nodes
# yum -y install http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Step: Enable glusterfs repository on both nodes
# wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo
Step:3 Install All the necessary Packages using yum  on both the nodes
# yum -y install pyxattr python-webob1.0 python-paste-deploy1.5 python-sphinx10 git autoconf automake bison dos2unix flex fuse-devel libaio-devel libibverbs-devel libtool libxml2-devel lvm2-devel make openssl-devel pkgconfig python-devel python-eventlet python-netifaces python-paste-deploy python-simplejson python-sphinx python-webob readline-devel rpm-build systemtap-sdt-devel tar
Step:4 Install the GlusterFS software on both nodes
#   yum install glusterfs{-fuse,-server}
#   yum install xfsdump xfsprogs
Step:5 Start glusterfs service  on both the nodes
# /etc/init.d/glusterd start ; chkconfig glusterd on
Step:6 Add fuse module to Linux core for GlusterClient on both the nodes.
# /sbin/modprobe fuse

To make it work after restart of server

# echo "modprobe fuse" > /etc/sysconfig/modules/fuse.modules
# chmod +x /etc/sysconfig/modules/fuse.modules
Step:7 Add Both nodes on trusted storage .

On ‘site1.nextstep4it.com’ , run below command .

#gluster peer probe site2.nextstep4it.com

On ‘Site2.nextstep4it.com’ , run below command

# gluster peer probe site1.nextstep4it.com

Note: If we are using firewall, make sure TCP ports 111, 24007, 24008, 24009  are open on site1.nextstep4it.com and site2.nextstep4it.com

To Check status of trusted storage using below command :

gluster-peer

Step:8 Create the below directory on both nodes.
#  mkdir -p /opt/gfs-data

On Master Node : site1.nextstep4it.com , Run below command

# gluster volume create apache replica 2 site1.nextstep4it.com:/opt/gfs-data site2.nextstep4it.com:/opt/gfs-data
Step:9 Now start the volume on both the nodes :
# gluster volume start apache

Now Mount volumes on site1.nextstep4it.com :

# mount.glusterfs site1.nextstep4it.com:/apache   /var/www/html

Also Mount the Volume on site2.nextstep4it.com :

# mount.glusterfs site2.nextstep4it:/apache /var/www/html

For the Permanent Mount add below entry in the /etc/fstab file.

site1.nextstep4it.com:/apache   /var/www/html  glusterfs defaults,_netdev 0 0
Step:10 Testing of File replications

Go To /var/www/html folders  , modify the files from ‘site1.nextstep4it.com’ check whether the changes are reflected on another node ‘site2.nextstep4it.com’.

Leave a Reply

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