How to install and configure GlusterFS on CentOS 7?

Windows Articles

How to install RainLoop (web-based email client) on Ubuntu 20.04?

Email plays an important role in companies and on a personal level. Sometimes it is convenient to have a personal email server,...

Fedora 33 available

Fedora is a Linux-based operating system, which also offers a development platform. In other words, it is free to use, modify, and...

Install GoAccess on Ubuntu 20.04?

Hello, friends. In this post, you will learn how to install GoAccess on Ubuntu 20.04. This way you will be able to...

The best lightweight web browsers

Hi! We currently spend a lot of time in front of the computer connected to the Internet. In fact, it is a...

Install Snowflake (SSH Client) on Ubuntu 20.04

Linux system administrators on servers have a big job behind them. Thanks to them, many of the services or tasks that an...
angeloma
angeloma
Senior Writer and partner

GlusterFS, is a multi-scalable file system for NAS initially developed by Gluster Inc. A Gluster would allow us to connect two machines that will write simultaneously on the same disc, agreeing on the writer.

Most of the GlusterFS functionalities are implemented as translators, including:

  • Mirroring and file replication.
  • Fragmentation of the files or Data striping.
  • Load balancing for reading and writing files.
  • Fault tolerant volumes.
  • I/O planning and disk caching.
  • The storage quotas.

In this tutorial, we will cluster using GlusterFS between two server machines that are using CentOS 7

0.- Requeriments

To make this turtorial we will use three computers with GNU/LINUX systems, must have at least 1gb of ram and use 64bits systems, also a separate hard disk in /dev/sdb.

Server 1:

  • Hostname: gluster1.osradar.local
  • O.S:  CentOS 7
  • Memory: 1gb
  • Ip Address: 192.168.1.9
  • Disk: 8gb /dev/sdb

Server 2:

  • Hostname: gluster2.osradar.local
  • O.S:  CentOS 7
  • Memory: 1gb
  • Ip Address: 192.168.1.10
  • Disk: 8gb /dev/sdb

1.- Configuring DNS (both nodes)

This first step is vital because GlusterFS uses name resolution to communicate between servers and clients. As root user you write to a terminal:

:~# nano /etc/hosts

And in the file it places the information of the nodes in the following way:

192.168.1.9 gluster1.osradar.local gluster1
192.168.1.10 gluster2.osradar.local gluster2

1.- DNS config on servers
1.- DNS config on servers

2.- Installing GlusterFS (both nodes)

To install Gluster we need to add its repository first, to do this, in a terminal we must write:

:~# yum install centos-release-gluster

2.- installing gluster repo package
2.- installing gluster repo package

When the package installation is complete, the repository will be added and we can now install GlusterFS.

:~# yum install glusterfs-server

3.- Installing GlusterFS
3.- Installing GlusterFS

Once the installation is complete, we can start the service:

:~# systemctl start glusterd
:~# systemctl enable glusterd

4.- Enabling and starting service
4.- Enabling and starting service

The next thing to do is to modify the firewall settings:

:~# firewall-cmd --zone=public --add-rich-rule='rule family="ipv4" source address="IP_ADDRESS_HERE" accept'
:~# firewall-cmd --reload

5.- Setting firewall rule
5.- Setting firewall rule

3.-Add a storage (both nodes)

Now we must prepare the second hard disk (/dev/sdb) to be used as a brick (basic storage unit in Gluster). We’ll do a partition there.

:~# fdisk /dev/sdb

To perform the process properly, write the options in this order

Command (m for help): n
Select (default p): p
Partition number (1-4, default 1): 1
press enter
press enter
Command (m for help): p
Command (m for help): w

6.- Creating a new partition
6.- Creating a new partition

now we proceed to format the partition:

:~# mkfs.ext4 /dev/sdb1

7.- Formating the partition
7.- Formating the partition

Then we create a folder and mount the partition on it.

:~# mkdir -p /data/glusterfs
:~# mount /dev/sdb1 /data/glusterfs

8.- Mounting the partition
8.- Mounting the partition

We make sure that the partition is automatically mounted at system boot:

:~# echo "/dev/sdb1 /data/glusterfs ext4 defaults 0 0" | tee --append /etc/fstab

9.- editing fstab
9.- editing fstab

4.-Configuring GlusterFS

The next step will be on node 1. tell Gluster that node 2 is trustworthy to build the cluster itself. To do this we must execute the following command:

:~# gluster peer probe gluster2.osradar.local

10.- Setup gluster peer
10.- Setup gluster peer

And then we verify that the other node has been added correctly with these commands:

:~# gluster peer status
:~# gluster pool list

11.- Checking the node added
11.- Checking the node added

5.- Creating GlusterFS Volume

We create a folder on both nodes that will serve as the volume folder:

:~# mkdir -p /data/glusterfs/glustervolume

12.- Creating a directory for new volume
12.- Creating a directory for new volume

We now proceed to create the volume by indicating that you will use two mirrors in this case:

:~# gluster volume create glusterfsvolumne replica 2 gluster1.osradar.local:/data/glusterfs/glustervolume gluster2.osradar.local:/data/glusterfs/glustervolume

13.- Creating gluster volume
13.- Creating gluster volume

We start the volume:

:~# gluster volume start glusterfsvolumne

14.- Starting the volume
14.- Starting the volume

The installation and configuration of glusterfs on a server is now complete. We proceed to install the client on another machine.

GlusterFS client

Now it is the customer’s turn to use another CentOS 7 device with an IP address of 192.168.1.7. The other features of the device do not influence the use of the device.

We proceed to install the glusterfs-client package:

:~# yum install glusterfs-client

Once the installation is finished, we will create a folder to mount the volume.

:~# mkdir -p /mnt/glusterfsvolumne

we set up the firewall:

:~# firewall-cmd --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.1.7" accept'
:~# ffirewall-cmd --reload

And we mount the previously created glusterFs volume.

:~# mount -t glusterfs gluster1.osradar.local:/glusterfsvolumne /mnt/glusterfsvolumne

15.- Mounting gluster volume on client node
15.- Mounting gluster volume on client node

We checked the mounting:

df -hP /mnt/glusterfsvolumne/

16.- checking the mounting
16.- checking the mounting

we add the entry in fstab so that it is automatically mounted:

:~# echo "gluster1.osradar.local:/glusterfsvolumne /mnt/glusterfsvolumne/ glusterfs  defaults,_netdev 0 0" | tee --append /etc/fstab

17.- editing fstab
17.- editing fstab

Testing the replication

First of all, in the server nodes, we execute the following commands:

On the first node (gluster1.osradar.local):

:~# mount -t glusterfs gluster2.osradar.local:/glusterfsvolumne /mnt

On second node (gluster2.osradar.local):

:~# mount -t glusterfs gluster1.osradar.local:/glusterfsvolumne /mnt

18.- Mounting the volumes
18.- Mounting the volumes

On client machine:

First we create the files, and verify

:~# touch /mnt/glusterfsvolumne/filetest{1..4}
:~# ls /mnt/glusterfsvolumne

19.- Creating example files
19.- Creating example files

Now from node 1 we show the files created from the client.

:~# ls -l /mnt/

20.- Testing the replication
20.- Testing the replication

That concludes the article and I hope it has served you well. Remember that for everything to work, you have to be careful with the firewall and define its rules correctly.

Please share this article through your social networks-

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to install RainLoop (web-based email client) on Ubuntu 20.04?

Email plays an important role in companies and on a personal level. Sometimes it is convenient to have a personal email server,...

Fedora 33 available

Fedora is a Linux-based operating system, which also offers a development platform. In other words, it is free to use, modify, and...

Install GoAccess on Ubuntu 20.04?

Hello, friends. In this post, you will learn how to install GoAccess on Ubuntu 20.04. This way you will be able to...

The best lightweight web browsers

Hi! We currently spend a lot of time in front of the computer connected to the Internet. In fact, it is a...

Install Snowflake (SSH Client) on Ubuntu 20.04

Linux system administrators on servers have a big job behind them. Thanks to them, many of the services or tasks that an...
x