In this article, We explain you the step by step procedure to Configure High Availability Linux Cluster on RHEL7 / CentOS7 for Web Server.
If you are interested in learning, Request you to go through the below recommended tutorial.
DevOps Full Course Tutorial for Beginners - DevOps Free Training Online
Docker Full Course Tutorial for Beginners - Docker Free Training Online
Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online
Ansible Full Course Tutorial for Beginners - Ansible Free Training Online
Openstack Full Course Tutorial for Beginners - Openstack Free Training Online
Previously we have used the Conga Software components for creating and managing the Clusters. Primary components are ricci and luci tools to configure a cluster on Linux, those are deprecated. Now all cluster configuration, operation and monitoring is performed using pcs configuration utility.
How to Configure High Availability Linux Cluster on RHEL7 / CentOS7
Our Lab Setup:
Hostname : Linux1 and Linux2
Management IP Address : 192.168.2.10(linux1) and 192.168.2.20(linux2)
Operating System : RHEL 7.1 - 64 Bit
Required Packages : pcs, pacemaker, fence-agents-all
Use the following instructions to install and configure the Web Server High Availability Linux Cluster on RHEL7 / CentOS7.
Prerequisites:
1. Make sure both nodes Linux1 and Linux2 are reachable.
2. Make an entry of each nodes for name resolution in /etc/hosts file or configure the nodes in DNS. Refer this link to configure the DNS Server on RHEL7 / CentOS7.
Steps involved to configure two node High Availability Cluster:
1. Install and Configure the Apache webserver (httpd Packages) on both nodes.
2. Enable the repo for High Availability Packages from ISO Image if needed or use public repos.
3. Install High Availability Cluster on both nodes
4. Configure High Availability Cluster.
5. Create resources for the service High Availabilty.
6. Start the High Availability Cluster
7. Relocate the Resources to other node.
8. Stopping the High Availability Cluster.
9. Start the High Availability cluster on specific node.
1. Install and Configure the Apache web server (httpd Packages) on both nodes.
Install the appropriate Apache Web server package "httpd" using yum to avoid dependencies issue. Refer the link to configure the Yum Repo Server - Configure YUM Repo Server on Linux.
yum -y install httpd*
Create a index.html under web server's default parent directory /var/www/html on both nodes.
echo "Displaying test home page from `hostname -d`" > /var/www/html/index.html
2. Enable the repo for High Availability Packages from ISO if needed or use public repo's.
To enable the repo to install the Cluster package, Copy the ISO and Mount it on /dvd.
mount /dev/cdrom /dvd
Add the below entry on existing repo file or create a new repo file.
[High-Availability]
name=RHEL7
baseurl=file:///dvd/addons/HighAvailability
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
3. Install High Availability Cluster on both nodes
Execute the below command to install the High Availability Cluster packages and its dependencies.
yum install -y pacemaker pcs fence-agents-all
4. Configure High Availability Cluster
Once we have installed High Availability Cluster packages, On both nodes, reset the password of the user "hacluster" which was created during the Cluster packages installation.
echo "redhat" | passwd --stdin hacluster
Start and Enable the pcsd Daemon on both nodes.
systemctl start pcsd
systemctl enable pcsd
Lets configure corosync, first authenticate the Cluster nodes membership using the user "hacluster"
pcs cluster auth linux1 linux2 -u hacluster
Just give the password of hacluster when its prompting for the password or just bypass the password like below.
pcs cluster auth linux1 linux2 -u hacluster -p redhat
where "redhat" is my hacluster password.
Configure the Cluster name and Cluster nodes as below on the same node to generate and synchronize the corosync configuration.
pcs cluster setup --name mycluster linux1 linux2
Start and Enable the High availability cluster.
pcs cluster start --all
pcs cluster enable --all
Once you have started, Cluster configuration file /etc/corosync/corosync.conf will be generated.
Check the High Availability Cluster Status
pcs status
5. Create resources for the service High Availability
Create the resources which are required to bring up the complete web service automatically by the cluster software. In our case, httpd service and Virtual IP are the resources. We call this resources also as service groups or resource groups.
pcs resource create VirtIP IPAddr ip=192.168.2.100 cidr_netmask=24 op monitor interval=30s
pcs resource create Httpd apache configfile="/etc/httpd/conf/httpd.conf" op monitor interval=30s
Set Constraint priority for the resources
pcs constraint colocation add Httpd with VirtIP INFINITY
Set Property for the resources
pcs property set stonith-enabled=false
pcs property set no-quorum-policy=ignore
pcs property set default-resource-stickiness="INFINITY"
Check the Cluster Resource status
pcs status resources
Once everything set, we could see the Virtual IP 192.168.2.100 has been assigned to our Ethernet card on the first node linux1.
Open the browser and check the status of the webserver using the url.
http://192.168.2.100
This will give you the output on the browser as "Displaying test home page from Linux1.learnitguide.net", because now the active node will be Linux1. So High Availability Cluster has been successfully configured. Now lets see how to check the fail over.
7. Relocate the Resources to other node for checking the fail over
Lets check the fail over of the resources by stopping the running node.
pcs cluster stop linux1
Check the cluster status
pcs status
Now output will show you as the resources are running on node linux2.
Open the browser and check the status of the webserver using the url.
http://192.168.2.100
This will give you the output on the browser as "Displaying test home page from Linux2.learnitguide.net", because now the active node is Linux2.
Note : For testing purpose to identify the active nodes, we use different index.html on each node. On production environment, these files should be same.
How to start High Availability cluster on specific node?
If you are going to do any activity on specific node, we can relocate the resources manually using the below command to not have any impact for the running services.
pcs cluster start nodename
How to modify existing High Availability cluster resources?
For example, if you wanted to change the virtual ip of web server as 192.168.2.200, then execute the below command and restart the cluster.
pcs resource update VirtIP IPAddr ip=192.168.2.200 cidr_netmask=24 op monitor interval=30s
Thats it. We are done with High Availability two node Cluster configuration for web server. Hope you have got an idea how to configure high availability linux cluster.
Related Linux contents that might be useful for you to improve your Linux Skills.
How to Configure IP Address on Ubuntu using Netplan
How to Access Linux Server from Windows Remotely
Configure SSH Passwordless Login Authentication (SSH-keygen)
How to Create LVM Partition in Linux – LVM Tutorial
Install & Configure Samba Server on Linux (RHEL7 / CentOS7)
How to Access Linux Server from Windows Remotely
Configure SSH Passwordless Login Authentication (SSH-keygen)
How to Create LVM Partition in Linux – LVM Tutorial
Install & Configure Samba Server on Linux (RHEL7 / CentOS7)
Keep practicing and have fun. Leave your comments if any.
Support Us: Share with your friends and groups.
Stay connected with us on social networking sites, Thank you.
configure high availability linux cluster, linux high availability cluster setup, configure ha server on linux, create high availability cluster on linux, linux ha cluster, ha cluster linux, linux ha cluster step by step, linux ha cluster howto, high availability cluster linux
0 Comments