The heartbeat program allows two machines to share a high availability address. Each machine has its own normal IP address used to administer the machine. There is then a third "service" IP address that SIP clients connect to. This normally runs on the primary machine as an IP alias eth0:0. The backup machine then monitors the health of the primary machine, and if it crashes the backup takes over the service IP address, again as eth0:0. The backup monitors the primary through the network and optionally through a null modem cable connected between the COM1 serial ports on each machine.
To configure heartbeat
Do the steps below on both machines. First, install the packages:
Debian / Ubuntu:
- apt-get install heartbeat
Redhat Enterprise:
The heartbeat packages must be installed from CD.
Others:
- yum -y install heartbeat
- chkconfig heartbeat on
Then:
- cd /etc/ha.d
- cp /opt/enswitch/current/install/etc/ha.d/* /etc/ha.d
- chmod 600 authkeys
- vi authkeys ha.cf haresources
- /etc/init.d/heartbeat start; tail -F /var/log/heartbeat.log &
When editing the configuration files, set the following:
- The sha1 password in auth keys. The actual value can be anything, but must be the same on both machines and should be hard to guess. Random characters is a good option.
- The udpport in ha.cf. This should not the same as any other heartbeat pairs (such as MySQL) on the same network. A suggested port is 696.
- The other machine's IP address in ha.cf.
- The gateway IP address in ha.cf.
- The hostnames of both machines in the "node" lines. These must be exactly the same as the output of the "hostname" command on each machine.
- If you are unable to connect a null modem cable between the machines, perhaps because they have no serial ports, remove the "baud" and "serial" lines.
- Check that /usr/lib/heartbeat/ipfail exists. If using a 64 bit machine, it may be /usr/lib64/heartbeat/ipfail instead; if so adjust the respawn line.
- The service IP address in haresources.
- Check that /etc/ha.d/resource.d/opensips and /etc/ha.d/resource.d/enswitch_sipd both exist as symlinks. If not, run "/opt/enswitch/current/bin/enswitch_install opensips-ha" again.