Heartbeat

Heartbeat is clustering solution which is apart of the Linux High Availability project developed to increase reliability, availability and serviceability of systems. The program sends out heartbeat packets to other members of the the heartbeat node. If a node fails to respond to a packet, then it is assumed that it is dead, all services are killed on that server and another node takes over its services.

Provides support for: web servers, mail servers, database servers, firewalls, routers/switches, DNS/DHCP, and proxy servers. Nodes can be setup so that they are logically using the same IP address so for the user the heartbeat cluster is transparent.

Installation and Configuration

Before installing hearbeat, there are some local changes that need to be performed.

Add IP addresses in /etc/hosts on all host clusters

vim /etc/hosts

127.0.0.1 localhost
192.168.1.2 nausicaa.anandhacorp.net
192.168.1.3 serfina.anandhacorp.net

Manually configure network device which will be used for hearbeat: /etc/sysconfig/network-scripts/ifcfg-eth0

vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
IPADDR=192.168.1.2
GATEWAY=192.168.1.10
BOOTPROTO=static
ONBOOT=yes

Install heartbeat using yum on fedora this will install all the dependancies required.

Installing manually using rpm require the following

rpm -ivh heartbeat-pils-1.2.2-8.rh.el.3.0.i386.rpm
rpm -ivh heartbeat-stonith-1.2.2-8.rh.el.3.0.i386.rpm
rpm -ivh heartbeat-1.2.2-8.rh.el.3.0.i386.rpm

We need to edit the configuration file /etc/ha.d/ha.cf. Note: this file may not exisit by default.
this files lists the clusters in the network and the configuration settings for them.

vim /etc/ha.d/ha.cf auto_failback on
debugfile /var/log/ha-debug
#
# File to write other messages to
#
logfile /var/log/ha-log
#
# Facility to use for syslog()/logger
#
logfacility local0
#
# keepalive: how many seconds between heartbeats
#
keepalive 2
#
# deadtime: seconds-to-declare-host-dead
#
deadtime 10
# What interfaces to heartbeat over?
#
bcast eth0
#
#
node nausicaa.anandhacorp.net
node serfina.anandhacorp.net
#

This configuration can be copied to all nodes

Generate authkey: /etc/ha.d/authkeys

The authkey contains pre-shared secrets used for mutual cluster node authentication. It should only be readable by root and follows this format: num is a simple key index, starting with 1. Usually, you will only have one key in your authkeys file. algorithm is the signature algorithm being used. You may use either md5 or sha1; the use of crc (a simple cyclic redundancy check, not secure) is not recommended. secret is the actual authentication key. You may create an authkeys file, using a generated secret, with the following shell hack:


( echo -ne "auth 1\n1 sha1 "; dd if=/dev/urandom bs=512 count=1 | openssl md5 ) > /etc/ha.d/authkeys

chmod the file to 600

Configure the resource file - this file specifies the services the cluster will run

vim /etc/ha.d/haresource

nausicaa.anandhacorp.net IPaddr::192.168.1.4 httpd smb

Included are httpd, smb and dhcpd. These services must be the exact same spelling as those daemons under /etc/rc.d/init.d

configure the same on second node, when services on both nodes are started an IP alias is created eth0:0 the primary node

start heartbeat

/etc/rc.d/init.d/heartbeat start

If you power down the primary node, the secondary node should automatically take over all services, add take on the IP alias eth0:0 192.168.1.4

Back to Resources