Howtos - Clustering with Heartbeat in Gateway Mode

Contents

Overview

This howto is a short introduction on implementing a cluster/failover solution for two ClarkConnect systems in gateway mode. If you want to build a cluster/failover solution for two standalone systems, please follow this howto.

Requirements

  • ClarkConnect 4.0/4.1
  • Static IP address

Installation

After installing your ClarkConnect system, you will need to install the Heartbeat software that supports gateway mode. In version 4.0/4.1, you can install the software with the following commands:

apt-get update
apt-get install heartbeat

Configuration

In our example, two ClarkConnect gateways are configured with same configuration, with one exception: the IP address used for the LAN interfaces should be different. In our example, we have:

  • Primary node - primary.lan:
    • eth0 - WAN IP: 216.58.8.84
    • eth1 - LAN IP: 192.168.1.2
  • Backup node - backup.lan:
    • eth0 - WAN IP: 216.58.8.84
    • eth1 - LAN IP: 192.168.1.3

In addition, 192.168.1.1 is used for the LAN IP address in the cluster. The cluster software will automatically switch this 192.168.1.1 between the primary and backup system. All systems on our LAN network would use 192.168.1.1 as the default gateway.

/etc/ha.d/ha.cf

On both the primary and backup server create the /etc/ha.d/ha.cf configuration file. Change the node parameters to suit your network. The node names much match the output from the uname -n command.

debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility daemon
keepalive 2
deadtime 10
bcast eth1
node primary.lan 
node backup.lan
auto_failback off
respawn hacluster /usr/lib/heartbeat/ipfail

/etc/ha.d/haresources

On both the primary and backup servers create the /etc/ha.d/haresources configuration file. The file is simply the node name of the primary server with the word Syswatch (capitalization is important!).

primary.lan Syswatch

/etc/ha.d/Syswath.conf

The heartbeat software needs to know the IP address used for clustering. In our example, the 192.168.1.1 IP address is on eth1. We configure these settings in /etc/ha.d/Syswatch.conf:

LAN_INTERFACE=eth1
LAN_IP=192.168.1.1

/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

After making the configuration changes, you are now ready to start the cluster:

  • Make sure the WAN network interface is disabled on both systems: /sbin/ifdown eth0
  • Make sure the heartbeat software is enabled to start on boot: /sbin/chkconfig --add heartbeat
  • Start the heartbeat software on the primary system: /sbin/service heartbeat start
  • Restart the system watch software on the primary system: /sbin/service syswatch restart

After a few seconds, you should see your cluster IP address (192.168.1.1 in our example) and the WAN IP address active. If not, check /var/log/messages for heartbeat issues, and /var/log/syswatch for network and firewall issues. Once the primary system is online, do the following on the backup system:

  • Make sure the heartbeat software is enabled to start on boot: /sbin/chkconfig --add heartbeat
  • Start the heartbeat software on the primary system: /sbin/service heartbeat start
  • Restart the system watch software on the primary system: /sbin/service syswatch restart

After a few seconds, check the /var/log/syswatch log file; you should see something similar to:

  • ... info: system - cluster node is backup - on standby

How It Works

Whenever a node changes its state (primary-to-backup or backup-to-primary), the /etc/ha.d/resource.d/Syswatch script is called. This script does two things:

  • Configures the cluster IP on the LAN (192.168.1.1 in our example)
  • Notifies the System Watch (syswatch) daemon that a change has taken place

The System Watch software manages the WAN interface and firewall. If the node is primary, it will configure the WAN interface (in future versions, this could be a DHCP or DSL/PPPoE interface) and restarts the firewall.

Links

Retrieved from "http://wiki.clarkconnect.com/docs/Howtos_-_Clustering_with_Heartbeat_in_Gateway_Mode"

This page has been accessed 1,840 times. This page was last modified on 7 January 2008, at 16:06.