Linux HA Heartbeat
From Debuntu
Contents |
Environment
This article is going to set up a Linux High-Availability cluster using Linux HA Heartbeat between 2 Debian Lenny host.
The configuration will be made in Heartbeatv1 mode.
The host are defined as follow:
- Host 1:
- Host name: lvs1
- Host IP: 172.16.137.130/24 on eth0
- Host 2:
- Host name: lvs2
- Host IP: 172.16.137.131/24 on eth0
- Failover IP: 172.16.137.135/24
Installation
Installation is pretty straightforward and is done with APT using the following command line:
# apt-get install heartbeat
Configuration
Enabling non-local IP binding
In order to be able to bind on a IP which is not yet define on the system, we need to enable non local binding at the kernel level.
Temporarily
For testing purpose, you can use the following command:
# echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind
Permanently
To enable it permanently, you need to add to /etc/sysctl.conf :
net.ipv4.ip_nonlocal_bind = 1
and then run:
# sysctl -p
Linux HA files
There is 3 files that we will need to edit:
- /etc/ha.d/authkeys identical on both hosts
- this file will contain the shared secret for nodes authentication within the cluster
- /etc/ha.d/ha.cf slightly different on host
- the global cluster configuration file.
- /etc/ha.d/haresources identical on both host
- Contains info on what resources are shared and who is the default master
Authkey
/etc/ha.d/authkeys will look like:
auth 1 1 md5 heartbeatmd5
Change heartbeatmd5 by any shared secret you would like.
This file will be identical on both hosts.
ha.cf
LVS1
On lvs1 /etc/ha.d/ha.cf will look like:
# keepalive: how many seconds between heartbeats keepalive 2 # deadtime: seconds-to-declare-host-dead deadtime 10 # warntime: set late heartbeat warning time warntime 5 # initdead: set initial deadtime detection interval initdead 120 # udpport: specifies port for UDP communication udpport 694 # ucast: configures unicast Heartbeat communication ucast eth0 172.16.137.131 logfacility local0 # auto_failback: set failback policy auto_failback off # node: tells what machines are in the cluster node lvs1 lvs2
LVS2
On lvs2 /etc/ha.d/ha.cf will look like:
# keepalive: how many seconds between heartbeats keepalive 2 # deadtime: seconds-to-declare-host-dead deadtime 10 # warntime: set late heartbeat warning time warntime 5 # initdead: set initial deadtime detection interval initdead 120 # udpport: specifies port for UDP communication udpport 694 # ucast: configures unicast Heartbeat communication ucast eth0 172.16.137.130 logfacility local0 # auto_failback: set failback policy auto_failback off # node: tells what machines are in the cluster node lvs1 lvs2
haresources
lvs1 172.16.137.135/24/eth0
Here we define that the IP 172.16.137.135/24 is will be running on eth0 and with preference for lvs1.
Running the service
Starting
The service can be started using:
# /etc/init.d/heartbeat start
Runtime status
You can get the status of your cluster by using the cl_status command line utility.
Here is an excerpt:
chantra@lvs1:~$ cl_status hbstatus Heartbeat is running on this machine. chantra@lvs1:~$ cl_status listnodes lvs2 lvs1 chantra@lvs1:~$ cl_status nodestatus lvs1 active chantra@lvs1:~$ cl_status nodestatus lvs2 active