Configuration of High Availability Cluster in CentOS and Red Hat Linux
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:
node2 :
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
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
Add the rule for the firewall
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:
node2:
Now to verify
Check out /dev/sdc 10GB drive can access by the both the node or not
node1:
node2:
Now go to any of the nodes
And create the pysical volume and volume group
From Node1
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
Now make entry in /etc/hosts file on the both the nodes
IP address :
node1 : 192.168.43.10
node2 : 192.168.43.152
Enables the Cluster Packages on both the nodes :
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
Now start and enable the pcsd services
systemctl start pcsd
systemctl enable pcsd
Now authorized both node host
Now Create the Cluster
Now set up the cluster to start automatically
pcs cluster enable — all
Check the status of the cluster
Want to know detailed information
pcs status
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
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
/usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -c “PidFile /var/run/httpd.pid” -k graceful > /dev/null 2>/dev/null || true
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
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
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
pcs resource create httpd_vip IPaddr2 ip=192.168.43.189 cidr_netmask=24 — group apache
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
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
Done :)