Server clustering software – Introduction
Server clustering software, also referred to as an availability cluster or HA cluster is a group of interconnected computer systems or servers that work together to ensure continuous operation and minimal downtime for critical applications and services. The primary goal of an HA cluster is to provide redundancy and fault tolerance, allowing for seamless failover in the event of hardware or software failures.
The key principle behind a Server clustering software is the concept of redundancy. By deploying multiple servers in a cluster, each capable of performing the same tasks, the cluster can continue functioning even if one or more servers become unavailable. This redundancy ensures that critical services remain accessible to users, preventing disruptions and maintaining business continuity.
There are four main categories for clusters:
Storage: Provide a consistent file system image to each server in a cluster so they can read from and write to a single shared file system at the same time.
High Availability: If a cluster node fails or becomes useless, services are transferred to another node in the cluster to minimize single points of failure.
Load Balancing: Send network service requests to several cluster nodes to balance the load by distributing a load of requests among the cluster nodes.
High Performance: Carry out simultaneous or concurrent processing to aid in enhancing application performance.
Local DNS Settings Configuration for Every Server
For the two servers to communicate with each other, we need to configure the appropriate local DNS settings in the /etc/hosts file on both servers.
Make changes to the file by opening it in your preferred command-line editor.
$ sudo vim /etc/hosts
Include the following entries together with your servers’ real IP addresses.
192.168.10.10 node1.example.com
192.168.10.11 node2.example.com
Close the file after saving the changes.
Setting up the Nginx Web Server
Installing the Nginx web server is now possible by using the steps below.
$ sudo apt install nginx [On Ubuntu]
$ sudo yum install epel-release && sudo yum install nginx [On CentOS 7]
Start the Nginx service after the installation is complete and then configure it to run every time the computer boots. Then, check its functionality using the systemctl command.
You may easily configure the service on Ubuntu so that it will start up automatically as soon as package pre-configuration is finished.
$ sudo systemctl enable nginx
$ sudo systemctl start nginx
$ sudo systemctl status nginx
We must build unique web pages to track and test server activities after launching the Nginx service. As demonstrated, we will alter the default Nginx index page’s content.
$ echo “This is the default page for node1.example.com” | sudo tee /usr/share/nginx/html/index.html #VPS1
$ echo “This is the default page for node2.example.com” | sudo tee /usr/share/nginx/html/index.html #VPS2
Corosync & Pacemaker Installation and Configuration
Next, each node has to have Pacemaker, Corosync, and Pcs installed as shown below.
$ sudo apt install corosync pacemaker pcs #Ubuntu
$ sudo yum install corosync pacemaker pcs #CentOS
Make that the pcs daemon is active on both servers when the installation is finished.
$ sudo systemctl enable pcsd
$ sudo systemctl start pcsd
$ sudo systemctl status pcsd
Creating the Cluster
During installation, the “hacluster” system user is created. As a result, we must set up the computer authentication needed. As we want the password for the “hacluster” user to be the same across all servers, let’s start by creating a new one:
$ sudo passwd hacluster
Make a password for the cluster user
|
Run the aforementioned command to set up the required PC authentication on any of the servers (Node1).
$ sudo pcs cluster auth node1.example.com node2.example.com -u hacluster -p password_here –force
On the Node1 server, construct a cluster and add several nodes to it (the cluster name must be more than 15 characters; in this example, we’ve used examplecluster).
$ sudo pcs cluster setup –name examplecluster node1.example.com node2.example.com
Start the service and activate the cluster now.
$ sudo pcs cluster enable –all
$ sudo pcs cluster start –all
Now use the following command to see if the cluster service is up and functioning.
$ sudo pcs status
OR
$ sudo crm_mon -1
The output of the command demonstrates that the STONITH is still activated in the cluster even in the absence of STONITH devices. Additionally, no cluster services or resources have been installed.
Setting Up Cluster Options
The first choice is to turn off STONITH, Pacemaker’s fence implementation, which stands for Shoot The Other Node In The Head.
This element aids in preventing concurrent access from tainting your data. Since we haven’t configured any devices, we will deactivate them for the duration of this instruction.
Run the given command to switch off STONITH.
$ sudo pcs property set stonith-enabled=false
Next, run the given command while disregarding the Quorum policy.
$ sudo pcs property set no-quorum-policy=ignore
Enter the given command to view the property list after setting the aforementioned options to make sure that the quorum policy, stonith, and the aforementioned parameters are all deactivated.
$ sudo pcs property list
A Resource/Cluster Service Added
We’ll look at adding a cluster resource in this part. To quickly transfer an IP address from one server to another within the same network or data centre, we will set up a floating IP. A floating IP is, technically speaking, an IP that connects to numerous interfaces only tangentially.
To enable failover in a cluster with high availability in this scenario, it will be employed. Keep in mind that floating IPs have a few other uses in addition to failover scenarios. The cluster must be set up so that only the member who is actively participating in the cluster “owns” or replies to the floating IP address at any one time.
Two new resources will be added to the cluster: “http_server” for the Nginx web server and “floating_ip” for a floating IP address. Two new resources will be added to the cluster: “http_server” for the Nginx web server and “floating_ip” for a floating IP address.
Start by first adding the floating_ip as shown below. Our movable IP address in this instance is 192.168.10.20.
$ sudo pcs resource create floating_ip ocf:heartbeat:IPaddr2 ip=192.168.10.20 cidr_netmask=24 op monitor interval=60s
floating_ip: is the service’s name.
“ocf:heartbeat:IPaddr2”:identifies the name space it is in (Pacemaker), the script to use (IPaddr2 in this example), and the ocf standard it complies with.
“op monitor interval=60s”:directs Pacemaker to contact the agent’s monitor action every minute to examine the status of this service.
The second resource, http_server, should then be added. Here, the service’s resource agent is ocf:heartbeat:nginx.
$ sudo pcs resource create http_server ocf:heartbeat:nginx configfile=”/etc/nginx/nginx.conf” op monitor timeout=”20s” interval=”60s”
The following command should be used to verify the status of resources after adding the cluster services.
$ sudo pcs status resources
The two additional resources “floating_ip” and “http_server” are listed in the command’s output. Because the main node is running, the floating_ip service is not active.
If your system is set up with a firewall, you must permit all traffic to Nginx and other high-availability services to pass through the firewall for proper communication between nodes:
————– CentOS 7 ————–
$ sudo firewall-cmd –permanent –add-service=http
$ sudo firewall-cmd –permanent –add-service=high-availability
$ sudo firewall-cmd –reload
————– Ubuntu ————–
$ sudo ufw allow http
$ sudo ufw allows high-availability
$ sudo ufw reload
High Availability/Clustering testing
Testing the functionality of the high-availability configuration is the last and most crucial phase. You should see the default Nginx page from node2.example.com when you open a web browser and go to the IP address 192.168.10.20, as seen in the image.s
Run the cluster-stopping command on node2.example.com to simulate a failure.
$ sudo pcs cluster stop http_server
Reload the page at 192.168.10.20 after that to view node1.example.com’s default Nginx web page.
As an alternative, you may mimic an error by issuing the service that follows the command on one of the nodes, terminating it without stopping the cluster on any node:
$ sudo crm_resource –resource http_server –force-stop
If crm_mon is run in interactive mode, which is the default, the cluster must be able to recognize that http_server failed and move it to another node within a monitoring interval of two minutes.
You may need to impose some restrictions for your cluster services to operate effectively. For a list of all use commands, visit the pcs man page (man pcs).
Final Thoughts
Deploying a Server clustering software requires careful planning, configuration, and ongoing maintenance. Factors such as network architecture, hardware redundancy, data replication, and failover mechanisms need to be considered to ensure the cluster’s effectiveness and reliability. Proper monitoring and management tools are also essential for proactive monitoring, troubleshooting, and timely intervention when issues arise.
In summary, a high-availability cluster is a collection of interconnected servers or computer systems designed to provide continuous operation, fault tolerance, and seamless failover in the event of hardware or software failures. Server clustering software employ redundancy and failover mechanisms to ensure critical services remain accessible, minimizing downtime and maintaining business continuity.
You can learn about linux more deeply by clicking the link below
https://linuxiron.com/what-is-linux-a-whole-introduction/
Learn about the other linux commands by clicking the links below
https://linuxiron.com/echo-command-in-linux/
https://linuxiron.com/how-to-use-nice-renice-commands-in-linux/
https://linuxiron.com/how-to-use-kill-commands-in-linux/
https://linuxiron.com/a-beginners-guide-to-htop-for-process-management/
https://linuxiron.com/15-useful-yum-commands-in-linux/
https://linuxiron.com/how-to-use-the-top-command-in-linux/
https://linuxiron.com/17-ps-command-to-monitor-linux-process-with-examples-linuxiron/
https://linuxiron.com/12-cat-commands-in-linux-with-examples/