Advertisment

Configure a Failsafe Cluster

author-image
PCQ Bureau
New Update

In this article we are going to see how easy it is to configure a highly available failsafe cluster for any Linux service. For this we will use a software framework called Heartbeat which is available on the website, www.linux-ha.org. The best part of this software is that it is completely service independent and you can run any and every Linux service on top of it. The concept of this software is very simple. The master node of this Heartbeat cluster generates a broadcast of UDP packets (Heartbeat) over a fixed interval of time and if the other node is unable to find that broadcast it determines that the node is dead and takes over the service after a given interval of time. 

Advertisment

Prerequisites



As we are creating a two-node failsafe cluster, the first prerequisite is that of having two machines: one to be the master node and the other to be the backup node. Now you need to name your machines. We set the fully qualified domain name of our master node as ‘master.pcquest.net' and the name of the backup node as ‘backup.pcquest. net'. The other thing you have to get is a cross-wired Cat-5 cable and four network cards. Two of the network cards will connect both the nodes to your main network, while the other two will connect the nodes to each other with the cross-wired cable. This will be used for determining the Heartbeat. When you are ready with all the hardware settings, install the version of Linux that you prefer. In our case, we used RedHat Enterprise Linux Advance Server. 



Here, let's assume some things. Let's say, the IP address of your master node's network card, which is connected to the other failsafe node with the cross-wire is 10.10.10.1 (/dev/eth1) and for the other node it is 10.10.10.2. And on the network cards, which are connected to the main network you can either take the IP address from the DHCP server or you can give the IP address manually. We gave 192.168.3.27 (/dev/eth0) IP address to the master node and 192.168.3.28 to the backup node. Now you will need to configure an alias for the network card of the master node, which is connected to the main network and give another IP address of the same network to the device. To do so, start the redhat-config-network applet and add a new LAN card. Here, when asked, select the same network card which is connected to your main network. This card will be given a device name, such as eth0:0. Assign an IP address to it such as 192.168.3.199. This will be the IP address of your cluster server and your service will respond to it.

Direct

Hit!
Applies

to:
System administrators
USP:

Configure a highly available failsafe cluster for Linux services
Links:

www.linux-ha.org 
Advertisment

Get your Heartbeat up



Installing this software is not difficult. Just copy the folder called HA from this month's Xtreme DVD to your home directory and install the software one by one like this.

#cp HA ~ -rf



#cd


#rpm : ivh heartbeat-pils-1.2.1-1.i586.rpm


#rpm : ivh openssl0.9.7-0.9.7c-52922cl.i386.rpm


#rpm : ivh perl*.rpm


#rpm : ivh heartbeat-stonith-1.2.1-1.i586.rpm


#rpm : ivh heartbeat-1.2.1-1.i586.rpm




One more thing to know here is that you have to install all of these files on both the nodes of your HA (High Availability) cluster. 

Advertisment

Here, the second network device (eth0:0) is the alias of the main network device

Configuring the cluster



Configuring the cluster consists of modifying three files: /etc/ha.cf, /etc/haresources and /etc/authkeys. But one thing that you have to keep a watch on is that the default files are copied by the rpms to /usr/ share/doc/packages/Heartbeat. So, you have to first copy all these files from here to /etc and after that start modifying them. The first file called ha.cf consists of all the settings for your nodes. Now you have to modify the following tags in this file for both the machines.

First open the file ha.cf form /etc and make the following changes: 

Advertisment

node master 



node backup


deadtime 30


warntime 10


bcast eth0 


auto_failback on



Leave the other options untouched. Next open haresources from /etc and provide the IP address as follows: 



master.pcqlabs.net IPaddr::192.168.3.199 httpd smb

This file should be identical in both the machines. Here you will notice that only one line is added. In this line we are assigning the DNS name of the master node and the IP address of the cluster and the services, which will run over Heartbeat. This means that now your network will have a failsafe cluster of Apache and Samba running over 192.168.3.199 (the IP allocated to the alias of the network card connected to the main network). 

Advertisment
Cat

5 cable combination
Connector



 A Pin#
Connector



   B Pin#
1 3
2 6
3 1
6 2
4 7
5 8
7 4
8 5

Finally, copy the file authkeys from the documents directory to the /etc directory in both the machines and you are done.



If you want to configure Heartbeat with more details and parameters then you can always read the comments in the same files before the tags.

Testing the cluster



Now comes the main part that of testing the cluster. Just shut down your master node and wait for 30 seconds. Then go to the backup node and run the ifconfig command. You will find that the alias eth0:0 is already created and the same IP

(192.168.3.199) is assigned to it. 

Note: In this article we haven't discussed how to configure your individual services such as SMB and httpd. For more details on them you can read the article Setting up Network Services, page 56, PCQuest, March 2004. The only thing to keep in mind is that you need exactly the same configurations for all the services in both the nodes.

Anindya Roy

Advertisment