Howtos - Clustering with Heartbeat
Overview
This howto is a short introduction on implementing a simple cluster solution with the Heartbeat software package.
Installation
After installing your ClarkConnect system, you will need to install the Heartbeat software. In version 4.0/4.1, you can install the software with the following commands:
apt-get update
apt-get install heartbeat
Configuration
Our example has the following setup:
- 192.168.2.1 - Router for the local network
- 192.168.2.2 - Primary machine: testbox.pointclark.net
- 192.168.2.3 - Secondary machine: beaker.pointclark.net
- 192.168.2.95 - IP address for cluster
For sanity checking purposes, we will use the Apache web server; you can use other servers of course. When both the primary and secondary machine are running normally, the web server running off of the primary server (192.168.2.2) will be available. When the primary server goes offline (pull the Ethernet plug), the secondary server will take over the cluster IP (192.168.2.95), and the web server running off the secondary server (192.168.2.3) will take over.
This example is called a "Basic Single IP Address Configuration" in the
Linux High Availability Documentation
 |
Warning! |
 |
| |
 |
|
In our example, the /etc/ha.d/ configuration files described below must be identical! |
|
/etc/ha.d/ha.cf
On both the primary and secondary server create the /etc/ha.d/ha.cf configuration file. Change the node and the ping parameters to suit your network. The ping parameter should be set with the IP address of your gateway. The node list format is important:
- the first node in the list is the primary server
- the node names must match the uname -n output
debugfile /var/log/ha-debug
logfile /var/log/ha-log
keepalive 2
deadtime 10
bcast eth0
node testbox.pointclark.net beaker.pointclark.net
auto_failback off
ping 192.168.2.1
respawn hacluster /usr/lib/heartbeat/ipfail
/etc/ha.d/haresources
On both the primary and secondary server create the /etc/ha.d/haresources configuration file. The file is simply the node name of the primary server, and the IP we are using for our cluster.
testbox.pointclark.net 192.168.2.95
/etc/ha.d/authkeys
The authkeys file simply authenticates nodes in the network. The file has the following format:
auth 1
1 sha1 <use dd command>
Replace the use dd command with output from the following command:
dd if=/dev/urandom count=4 2>/dev/null | md5sum | cut -c1-32
Also, make sure the file permissions on /etc/ha.d/authkeys are strict:
chmod 600 /etc/ha.d/authkeys
Finishing Up
The Heartbeat software package can be combined with Data Redundancy with DRBD package to create a failover file server solution. The only change required is the /etc/ha.d/haresources file.
Links
|