[HOWTO] Heartbeat
Note: Both Servers running the same hardware specification
1.0 Connecting & Setting Two Nodes (Servers)
Figure 1.0: Connecting primary and secondary servers with null modem cable and cat-5 cross over cable
Heartbeat is one of the program used to provide high availability (HA) to servers. It is a IP fail-over program. Where two servers, one primary and one secondary, when the primary server fails, the secondary server will take over the primary server's IP address. Hence, it will not caused downtime due to primary server failure. The above figure, represents how both servers are connected and ensure IP fail-over works.
Primary server will take back its IP address once it's booted up.
1.1 Set the local IP address for Heartbeat to communicate.
Primary Server * using eth1
# vi /etc/sysconfig/network-script/ifcfg-eth1
IPADDR=10.0.0.1
NETMASK=255.255.255.0
Secondary Server * using eth1
# vi /etc/sysconfig/network-script/ifcfg-eth1
IPADDR=10.0.0.2
NETMASK=255.255.255.0
Next, ping both IP address from both servers, make sure there are replies.
1.2 Test the Null Modem Serial Cable
Do the following simultanously to monitor the connection:
(receiver) Primary Srv shell: $ cat < /dev/ttyS0 (sender) Secondary Srv shell: $ echo hello > /dev/ttyS0
(receiver) Primary Srv shell: $
(receiver) Primary Srv shell: hello
The primary server which is a receiver ( cat < /dev/ttyS0 ) must be able to receive the message 'hello' from secondary server. Try again, primary become sender and secondary become receiver.
2.0 Installation
2.1 Installing...
Install libnet.tar.gz
Download heartbeat stable version and two (2) dependency files from:
Heartbeat-pils-1.2.3
Heartbeat-stonith-1.2.3
Download to /usr/src
# cd /usr/src
# rpm -iUvh heartbeat-pils-1.2.3-2.fr.c.1.i386.rpm
# rpm -iUvh heartbeat-stonith-1.2.3-2.fr.c.1.i386.rpm
# rpm -iUvh heartbeat-1.2.3-2.fr.c.1.i386.rpm
2.2 Post Installation
Move the configuration files to /usr/local/etc/ha.d
# cd /usr/share/doc/heartbeat-1.2.3
# cp ha.cd /etc/ha.d
# cp haresources /etc/ha.d
# cp authkeys /etc/ha.d
3.0 Configuring Heartbeat.
* NOTE: Performed the SAME configuration on BOTH primary and secondary server.
3.1 /etc/ha.d/ha.cf
Edit the ha.cf with the following configuration.
# vi /etc/ha.d/ha.cf
serial /dev/ttyS0
baud 19200
bcast eth1
udpport 694
keepalive 2
deadtime 30
node
node
logfile /var/log/ha-log
initdead 120
auto_failback on
respawn hacluster /usr/lib/heartbeat/ipfail
3.2 /etc/ha.d/haresouces
Edit the virtual IP (cluster IP) in this file, /etc/ha.d/haresources
# vi /etc/a.d/haresources
3.3 /etc/ha.d/authkeys
# chmod 600 /etc/ha.d/authkeys
# vi /etc/ha.d/authkeys
auth 3
3 md5
The following command to start and stop heartbeat
# /etc/rc.d/init.d/heartbeat start
# /etc/rc.d/init.d/heartbeat stop
# /etc/rc.d/init.d/heartbeat status
