The cart is empty

In today's digital world, continuous availability of services is crucial for businesses of all sizes. One proven solution for ensuring high availability (HA) of applications and services is to create a cluster. This article will focus on the process of creating and configuring an HA cluster using Pacemaker and Corosync on the CentOS 7 operating system.

Prerequisites

For this tutorial, we will assume that you have two servers running CentOS 7, connected in a network and assigned static IP addresses. We will also assume that you have full administrative rights on both servers.

Software Installation

First, it's necessary to install the required software - Corosync, Pacemaker, and cluster management tools - on both servers. This can be done using the following commands:

sudo yum install -y pacemaker corosync pcs fence-agents-all

After installation, it is important to enable and start the pcsd service (Pacemaker/Corosync Configuration System Daemon) on both servers:

sudo systemctl enable pcsd
sudo systemctl start pcsd

Authentication Configuration

For the servers in the cluster to communicate reliably, mutual authentication needs to be set up. Create and synchronize a cluster management user on both servers using the command:

sudo pcs cluster auth node1 node2 -u hacluster -p <password>

Here, node1 and node2 are the hostnames or IP addresses of your servers, and <password> is the password you choose for the hacluster user.

Creating the Cluster

After successful authentication, you can create the cluster. The following command defines a new cluster named my_cluster:

sudo pcs cluster setup --name my_cluster node1 node2

Then, the cluster needs to be started on both servers:

sudo pcs cluster start --all

Corosync and Pacemaker Configuration

For the HA cluster to function correctly, it's crucial to properly set up Corosync and Pacemaker. The Corosync configuration involves defining communication protocols and addresses, while Pacemaker allows for the management of resources and HA policies.

Basic settings for the cluster can be configured using the web interface or the pcs command line. For example, to set basic policies for service restart in case of failure:

sudo pcs property set stonith-enabled=false
sudo pcs property set no-quorum-policy=ignore

Testing the Cluster

After configuration, it's important to test the cluster. You can, for example, create a test resource and observe how the cluster behaves during its failure:

sudo pcs resource create my_resource ocf:pacemaker:Dummy op monitor interval=30s

Then, you can simulate a service failure and watch how the cluster reacts and moves resources to the other node.

 

Creating and configuring a high availability cluster solution using Pacemaker and Corosync on CentOS 7 requires careful preparation and understanding of HA concepts. This article provided you with a basic overview of how to get started. It's important to continue experimenting with different configuration options and testing your cluster in various scenarios to ensure its maximum efficiency and resilience.