Monday, August 12, 2013

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/

No comments:

Post a Comment