How to Install and Configure HA Cluster with PCS on Debian

How to Install and Configure HA Cluster with PCS on Debian

- 4 mins

Why HA?

High-availability software is used to operate high-availability clusters. In a high-availability IT system, there are different layers (physical, data link, network, transport, session, presentation, and application) that have different software needs. If a server in the cluster fails, another server or node can take over immediately to help ensure the application or service supported by the cluster remains operational. Using high-availability clusters helps ensure there is no single point of failure for critical IT and reduces or eliminates downtime. HA is a critical feature for your servers. Using HA Clusters should be good searced there are many diffrent HA structure (Data, Traffic, Load balancing, A/A, A/P …)

Prerequisites

Today I will try to tell creating HA Cluster with Pacemaker and Corosync with 2 Debian 10 VM. We need to have 2 different Linux VM for creating a cluster. Be aware that necessary security rules (Firewall, ssh and some ports depends of your Linux distro) and networking(2 dynamic or static IP) should be done.

Install Pacemaker and Corosync

  1. The first step is to install PCS, Pacemaker and Corosync on both nodes. To do this, open terminal and run following command −
sudo apt install pcs corosync pacemaker

Configure Cluster

The next step is to configure cluster. We will start by configuring Corosync cluster messaging system. To do this, open file /etc/corosync/corosync.conf in your preferred text editor and add following lines −

totem {
   version: 2
   secauth: off
   cluster_name: mycluster
   transport: udpu
}

nodelist {
   node {
      ring0_addr: 192.168.64.13
      name: debian1
   }

   node {
      ring0_addr: 192.168.64.14
      name: debian2
   }
}

Start Corosync Service

  1. You should start the service
sudo systemctl start corosync

coro

Configure Pacemaker Cluster Resource Manager

The next step is to configure Pacemaker cluster resource manager. To do this, open file /etc/pacemaker/pcs.conf in your preferred text editor and add following lines

pcs cluster setup --name mycluster <hostname of node 1> <hostname of node 2>
pcs cluster enable --all

pcs

Replace <hostname of node 1> and <hostname of node 2> with hostnames of two nodes.

Configure Cluster Resources

The final step is to configure cluster resources. We need start by configuring a virtual IP (Floating IP) for HA. Floating IPs (now named Reserved IPs). A Floating IP is an IP address that can be instantly moved from one Droplet to another Droplet in the same datacenter.

pcs resource create virtual_ip ocf:heartbeat:IPaddr2 ip=<IP address of virtual IP> cidr_netmask=24 op monitor interval=30s
sudo pcs config

pcs2

pcs resource create apache ocf:heartbeat:apache

Verify Cluster Status

pcs3

sudo systemctl stop pacemaker

pcs5

:metal: :metal: :metal: :metal: :metal: :metal: :metal:


:bulb: Never stop learning, beacuse life never stops teaching.

:memo: Thanks for reading.

Guneycan Sanli.


Guneycan Sanli

Guneycan Sanli

A person who like learning, music, travelling and sports.

comments powered by Disqus