Recent

Configure High Availability Linux Cluster on RHEL7/CentOS7

Configure High Availability Linux Cluster on Rhel7/CentOS7

In this article, We explain you the step by step procedure to setup High Availability Linux Cluster on RHEL7 / CentOS7 for Web Server.

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.

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.

Also read more about,
Cluster Basics
Linux Clusters
Veritas Cluster (VCS)
HP ServiceGuard Cluster
Cluster Tutorial Videos

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 the 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 the 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.

Also read more about,
Cluster Basics
Linux Clusters
Veritas Cluster (VCS)
HP ServiceGuard Cluster
Cluster Tutorial Videos

Thanks for reading our post. share with your friends. We appreciate your feedback, Leave your comments if any.
We have more articles to be updated soon. To not miss any updates, Follow us on social networking sites and Subscribe us on our You tube channel.
Configure High Availability Linux Cluster on RHEL7/CentOS7 thumbnail Reviewed by Blog Admin on 19:44 Rating: 5

No comments:

All Rights Reserved by Learn IT Guide © 2015 - 2025.

Contact Form

Name

Email *

Message *

Powered by Blogger.