Deploying a Highly Available Cluster (Heartbeat) on CentOS

Here the Heatbeat Program is configured to work over a seperate physical connection between the 2 servers (over the private switch). The seperate connection between the 2 servers can be either a serial cable or another ethernet network connection via cross-over cable or a mini switch.

Do note that it is recommended to use at least 2 seperate physical connection to eliminate a single point of failure. As such both of your servers will need 2 phyiscal NIC to allow this 2 seperate physical connection design

Step 1: Configuring the IP addresses
Firstly, do note that RFC 1918 defines the following IP addresses for private network to (10/8 prefix) to 172.31..255.255 (172.16/12 prefix) to (192.168/16 prefix)

For the master node, I will be configuring the IP Addresses as followed: for eth0 (private LAN for the private physical path for the the heartbeat) for eth1 (existing corporate LAN for the other physcial path for the heartbeat

For the slave node, I will be configuring the IP Addresses as followed: for eth0 (private LAN for the private physical path for the heartbeat) for eth1 (existing corporate LAN for the other physical path for the heartbeat)

For the Virtual IP Address, I will be configuring the IP Addresses as followed: (for Virtual Address)

Verify the name of the master node and slave nodes

uname -n
(n01 for master node; n02 for slave node)

Step 2: Install and configure the Heartbeat

# yum install heartbeat

Now we have to configure 3 of the files for the 2 nodes. They are


Copy the sample files to the /etc/ha.d directory

cp /usr/share/doc/heartbeat-2.1.2/authkeys /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.2/ /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.2/haresources /etc/ha.d/

Step 3: Configuring the /etc/ha.d/

logfile /var/log/ha-log
logfacility local
warntime 5
keepalive 2
deadtime 15
initdead 60
bcast eth0 eth1
udpport 694
auto_failback off
node n01 n02
  1. keepalive – specifies how many seconds there should be there between heartbeats
  2. deadtime – specifies how many seconds how long the backup will wait without receiving a heartbeat from the primary server before taking over
  3. initdead – specifies that after the heartbeat daemon starts, it should wait 120 seconds before starting any resources on the primary server.
  4. warntime – issues a warning that a no longer available peer node may be dead
  5. nodes n01 n02 is generated by uname -n
  6. auth_failback off – If the master server fail, the slave server will hold up the resources and will not return the control to the master server when it is brought back live. If auth_failover on, once the master server is brought back online, the slave server will return the resource back to the master server

Step 4: Configure the /etc/ha.d/authkeys

Edit and uncomment the line so that the lines inside /etc/ha.d/authkeys so like this

auth 1
1 sha 1 password
  1. 1  – is a simple key index, starting with 1
  2. sha 1 – the signature algorithm being used. You may use either md5 or sha1
  3. password – refer to the password you create. Make sure it is the same on both systems

Change the permission of the authkeys file

chmod 600 /etc/ha.d/authkeys

Step 5: Configure /etc/ha.d/haresources

The /etc/ha.d/haresources file contain the name of the resources the master server should own. Name of resources are usually a scripts found in /etc/init.d/(script) or /etc/ha.d/resource.d directory. If you stop the heartbeat daemon, you will stop the resource daemon (For example httpd) will not run.

n01 httpd

(where n01 is the master server and the httpd is the resource daemon handled by heartbeat )

Step 6: Install the Heartbeat and configure the backup server 

Install the heart-beat according to Step 2. Next copy all the configuration file to the slave server

scp -r /etc/ha.d/ root@n02:/etc/

Copy the resource daemon heartbeat is running from the master server to the slave server. For this example, we will assume httpd

scp /etc/httpd/conf/httpd.conf root@n02:/etc/httpd/conf/

Step 7: Start and test the heartbeat on master (n01) and slave nodes (n02)

/etc/init.d/heartbeat start (Virtual IP Address)

Stop the master node heartbeat and type

/etc/init.d/heartbeat stop (Virtual IP Address)

(n02 should show hold the daemon)

Further reading:

  1. Deploying ipfail plug-in for HeartBeat (Linux Cluster)

For more information, do look at

  1. Heartbeat User’s Guide 3.0
  2. Configuring A High Availability Cluster (Heartbeat) On CentOS
  3. Linux-HA


One thought on “Deploying a Highly Available Cluster (Heartbeat) on CentOS

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s