Configuration of High Availability Cluster in CentOS and Red Hat Linux

Sourabh Dey
8 min readJan 20, 2022

--

High Availability Cluster, also known as Fail-over Cluster or active-passive cluster it’s one of the most widely used cluster type in a production enviroment to have continuation availability of services even one of the cluster nodes get fails.

In-technical Term : If the server running application has failed for some reason (ex: Hardware failure, Cluster Software pacemaker) will restart the application on the working node.

Here We will configure a fail-over cluster with Pacemaker to make the apache web server as a highly available application.

Requirement

Machine Ip

node 1 192.168.43.197 Cluster Node1

node2 192.168.43.245 Cluster Node2

storage ISCSI 192.168.43.122 ISCSI Shared Storage

Virtual Host 192.168.43.189 Virtual Cluster IP (apache) Hosting

ICSCI Server Configuration

package Reqirement :

yum install targetcli lvm

Node1 Configuration

yum install iscsi-initiator-utils lvm2

Node2 Configuration

yum install iscsi-initiator-utils lvm2

Now go to the ISCSI Server and Set up share storage disk

In my case I add 10GB storage in my server

sudo fdisk -l | grep -i sd

Create the physical Volume

Create the Volume Group

Create the logical Volume

sudo lvcreate -l 100%FREE -n lv_iscsi vg_iscsi

Now go to both the nodes to generate iqn number

node1:

InitiatorName=iqn.1994–05.com.redhat:37cf5212daf4

node2 :

InitiatorName=iqn.1994–05.com.redhat:37cf5212daf5

Change the directory

Now go to the ISCSI Server

Now Create a shared storage object

create iscsi_shared_storage /dev/vg_isci/lv_iscsi

Now go to the iscsi directory

cd /iscsi

It will create target Iqn number with target Portal group

Now go to the acls directory

cd iqn.2003–01.org.linux-iscsi.localhost.x8664:sn.c4556f519ba9/tpg1/acls

Create storage for mapping in both the nodes

create /backstores/block/iscsi_shared_storage

Save the configuration and exitis

cd /

savconfig

Now start the target service and enable also

Service is started and active

Add the rule for the firewall

ICSCI Traffice will used this port 3260

iscsiadm — open-iscsi administration utility

Now we need to map this on both the node

Node1 output :

Node2 Output:

Now Map this on both the node

node1:

node1

node2:

node2

Now to verify

Check out /dev/sdc 10GB drive can access by the both the node or not

node1:

node1 can access the disk through icsci server

node2:

node2 can access the disk through icsci server

Now go to any of the nodes

And create the pysical volume and volume group

From Node1

Create the logical volume
Format it and convert it into the ext4 type

Now go to the node2 all the physical and logical volume group must be shown from the node2 also

To see more details of the lvm from the other node

We able to see the details of the lvm from the node2

Now make entry in /etc/hosts file on the both the nodes

IP address :

node1 : 192.168.43.10

node2 : 192.168.43.152

Add both nodes ip address in both the nodes machine

Enables the Cluster Packages on both the nodes :

Enable on both the nodep

dnf — enablerepo=ha -y install pacemaker pcs node1

dnf — enablerepo=ha -y install pacemaker pcs node2

CENT OS 8

sudo yum install pcs fence-agents-all pcp-zeroconf node1

sudo yum install pcs fence-agents-all pcp-zeroconf node2

Add the service to the firewall :

sudo firewall-cmd — permanent — add-service=high-availability

done this both the node
done this on both the node
Done this on both the node

Now start and enable the pcsd services

systemctl start pcsd

systemctl enable pcsd

Enable and Start both in both node

Now authorized both node host

Now Create the Cluster

Output :)

Now set up the cluster to start automatically

pcs cluster enable — all

Output shown be like this

Check the status of the cluster

Bingo both are online :)

Want to know detailed information

pcs status

Output of the above command

If you are using fencing devices please ignore the line if you are not using any fencing devices please input this command :

Now install Apache on both the node :

yum install httpd -y install that on both the node

Go to the configuration file

/etc/httpd/conf/httpd.conf

Add the line on both the node

Edit the apache web server logrotates configuration to tell not to use systemd as cluster don’t use systemd to reload the service

/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true

On both the node

/usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -c “PidFile /var/run/httpd.pid” -k graceful > /dev/null 2>/dev/null || true

on both the node

Now we will use the shared storage for storing the web content HTML file . Perform below operation in any one of the node.

Mount the lvm in /var/www/html on node 1

mount

Mount the lvm
Make the directory from node1

Made some test file in index.html in /var/www/html

Now unmount the /var/www

Add Apache service in the firewall

sudo firewall-cmd — permanent — add-service=http

firewall-cmd — reload

Input on both the node

Create a filesystem resources for the apache server . Use the storage coming for the ISCSI Server

sudo pcs resource create httpd_fs Filesystem device=”/dev/mapper/vg_apache-lv_apache” directory=”/var/www” fstype=”ext4" — group apache

Output of the command

pcs resource create httpd_vip IPaddr2 ip=192.168.43.189 cidr_netmask=24 — group apache

Here is the IP Address of the virtual IP refer top of the article please
Bingo hearbeat IPaddr2 deducted

Now create an apache resource to monitor the status of the apache server that will move the resorces to the another node in case if any allow !

Now check the status :

Now enough of setting the infrastructure it’s time of checking our configuration:

Open your favourite browser :

and type the Virtual IP address : 192.168.43.189 in my case

Bingo we are able to see the web page

Now we have to check if all the node are working properly or not

Let’s make node1 in stand by if our configuration is correct the web page still be showing

Node2 in stand by node but still our HA cluster is working
it’s still showing

Done :)

--

--

Sourabh Dey
Sourabh Dey

Written by Sourabh Dey

Trying To learn as much as possible about different Techonology. About me I am just a normal Boy who lives in terminal

No responses yet