Monday, August 12, 2013

HeartBeat Investigation

Questions to ponder:

1. After setting up two servers with heartbeat, use ping/apache to test the setup, remove the LAN cable on the primary server then observe what will happen and what is the average delay before the service responds again. (You need to get the average so you need to test the setup at least thrice). What value on the ha.cf matched or is near on the result of your investigation?

ScreenShots for the first 2 servers


2. Setup three to four servers with heartbeat on each server. The set up must have a primary server and the rest are secondary/slave servers. Remove the LAN cable on the primary server, what will happen next. Also observe the response time of the secondary server.

3. From your latest set up, remove the LAN Cable from the slave that responded earlier and observe what will happen

Some more screenshots




The average delay time before the service responds for all servers is about 0.948 for the three servers, with each of the servers when removing the LAN the server responds a bit slower in comparison with the primary server

Server Backup using Heartbeat and Apache

In our exercise we needed to setup a network configuration where one server will take the role of the other server whenever it is unavailable

First we installed the following application using ubuntu

Apache
Heartbeat
Pacemaker

with the use of the apt-get install command of ubuntu

Next we use three computers, the first two will act as a server while the third one will be the client that will connect to a server

first we set Server 1&2 file “/etc/hosts” with the following:
127.0.0.1       localhost
192.168.1.2   server2
192.168.1.1   server1
192.168.1.3    cluster

next edit “/etc/ha.d/authkeys”

auth 1
1 md5 onethreeseven

and we made it unreadable for non-root users:

chmod 0600 /etc/ha.d/authkeys


Then we edit “/etc/ha.d/ha.cf” to look similar like this one:

logfacility local0 #used to tell heartbeat which log facility to utilize for logging
keepalive 2 #interval between heartbeat packets currently every 2 secs you could also use 2000ms
deadtime 5 # timeout before the other server takes over
ping 192.168.1.2 #address to ping to determine if we are alive
udpport 694 #port to listen in on for broadcasts made by heartbeat
bcast eth1 #device to use for broadcasts
node server1 # hostname of one of our two nodes
node server2 # hostname of other of our two nodes
auto_failback on # very important or auto failover won't happen

This is the config for server 1, 192.168.1.2 is the address of server 2.

You have to place the IP of server1 in the file on server2 too.


Then duplicate we “/etc/ha.d/haresources” and “/etc/ha.d/authkeys” to server2.

Finally, start Heartbeat on both Servers:

/etc/init.d/heartbeat start

/etc/ha.d/authkeys

/etc/ha.d/ha.cf

/etc/ha.d/haresources

/etc/hosts


References:

http://www.langeder.org/wordpress/high-available-server-using-heartbeat/