Centos 7 GlusterFS Setup

on June 30, 2015, 10:10 p.m.

A little about the setup before I begin with the actual setup. I created 3 Centos 7 servers with 1 20gb hard disk and 1 200gb hard disk. Since these 3 machines are virtual, it just seemed easier to do this to keep the data separate from the OS disk. Then I installed Centos and set a static IP for each. The following set of commands needs to be run on all 3 servers.

Install the gluster repo:
curl http://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-epel.repo -o /etc/yum.repos.d/glusterfs-epel.repo

Install the epel repo:
yum install epel-release

Delete repo cache:
yum clean all

Install the glusterfs server
yum -y install glusterfs-server

Create partition on data disk:
fdisk /dev/vdb

Extend the main volume group to cover the new disk
vgextend centos /dev/vdb1

Add logical volume to volume group named data and assign it all the space available
lvcreate -l100%FREE -n data centos

Format the new volume group
mkfs.ext4 /dev/mapper/centos-data

Add firewall rules to allow the 3 servers to talk
firewall-cmd --permanent --zone=trusted --add-source=
firewall-cmd --permanent --zone=trusted --add-source=
firewall-cmd --permanent --zone=trusted --add-source=
firewall-cmd --reload

Start and enable the gluster server
systemctl start glusterd
systemctl enable glusterd

Make directory for gluster
mkdir -p /data/glusterfs

Add host entries so each node knows where the other is
echo " gfs01" >> /etc/hosts
echo " gfs02" >> /etc/hosts
echo " gfs03" >> /etc/hosts

Probe each server to make sure it responds
gluster peer probe gfs01
gluster peer probe gfs02
gluster peer probe gfs03

Check peer status
gluster peer status

Create the glusterfs volume to share. The following command creates 3 copies of all data so each node has a copy of the file
gluster volume create data replica 3 \
gfs01:/data/glusterfs \
gfs02:/data/glusterfs \

Start the data volume
gluster volume start data

Check the glusterfs status
gluster volume info

The following is for the client install and mounting of the share:

curl http://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-epel.repo -o /etc/yum.repos.d/glusterfs-epel.repo
yum -y install glusterfs glusterfs-fuse
mount -t glusterfs gfs03.pingnattack.com:/data1 /mnt
df -hT