UnixServerAdmin

Server Administration & Management

How to install and configure Failover “OR” High Availability (HA) Cluster with heartbeat in Apache

Heartbeat is a High Availably cluster software in linux platform. Here is following steps to  install and configure Heartbeat in RHEL/CentOS configure web server using Apache.

Heartbeat Version is : heartbeat-3.0

===========================================
Requirements :-

2 linux nodes, RHEL 5.x/CentOS 5.x
LAN & Internet connection.
A yum server.

Node-1: 192.168.3.201
Node-2: 192.168.3.202

Virtaul IP Address (VIP) :- 192.168.3.135
===========================================

1. Set the fully qualified hostnames and give corresponding entries in /etc/hosts and /etc/sysconfig/network

node-1 :- 192.168.3.201 :- node-1.unixserveradmin.com
node-2 :- 192.168.3.202 :- node-2.unixserveradmin.com

2. Configuring Apache on both node

# yum install httpd mod_ssl

On node1

# vim /var/www/html/index.html
This is test page of node 1 of Heartbeat HA cluster

On node2

# vim /var/www/html/index.html
This is test page of node 2 of Heartbeat HA cluster

On both nodes:

# vim /etc/httpd/conf/httpd.conf
Listen 192.168.3.135:80

3. Now start the service in both nodes.

# /etc/init.d/httpd restart  

# chkconfig httpd on

Note:- It won’t work until heartbeat is started. So don’t worry

4. Confirm them from broswer.

5. Install the following packages in both nodes:
(These below packages are not necessary, but you can install it.)

# yum install glibc*

# yum install gcc*

# yum install lib*

# yum install flex*

# yum install net-snmp*

# yum install OpenIPMI*

# yum install python-devel

# yum install perl*

# yum install openhpi*

6. Save the repo file for clusterlabs online repository in both node. Its available in http://www.clusterlabs.org/rpm/epel-5/clusterlabs.repo

# cd /etc/yum.repos.d/

# wget http://www.clusterlabs.org/rpm/epel-5/clusterlabs.repo

it is as follows:
————————————————————–
[clusterlabs]
name=High Availability/Clustering server technologies (epel-5)
baseurl=http://www.clusterlabs.org/rpm/epel-5
type=rpm-md
gpgcheck=0
enabled=1
————————————————————–

7. After that install heartbeat packages on both nodes:

# yum install cluster-glue* heartbeat* resource-agents*

8. Setting Configuration files:

We can do all configuration in one system and copy the /etc/ha.d to both nodes.

#cd /etc/ha.d

#cat README.config

9. The details about configuration files are explained in this file. We have to copy three
configuration files to this directory from samples in documentation.

# cp /usr/share/doc/heartbeat-3.0.3/authkeys /etc/ha.d/
# cp /usr/share/doc/heartbeat-3.0.3/ha.cf /etc/ha.d/
# cp /usr/share/doc/heartbeat-3.0.3/haresources /etc/ha.d/

10. We have to edit the authkeys file on both nodes:

We are using sha1 algorithm:

# vim /etc/ha.d/authkeys
—————
auth 2
#1 crc
2 sha1 test-ha
#3 md5 Hello!
—————

11. Change the permission of authkeys to 600 to both nodes:

# chmod 600 authkeys

12. We have to edit the ha.cf file on both nodes:

# vim /etc/ha.d/ha.cf

uncomment following lines and make edits
—————————————–
logfile /var/log/ha-log
logfacility local0
keepalive 1
deadtime 15
warntime 10
initdead 120
udpport 694
bcast eth0
auto_failback on
node node-1.unixserveradmin.com # in both nodes command “uname -n” should give the these hostnames
node node-2.unixserveradmin.com
—————————————–

13. We have to edit the haresources file on both nodes separately:

on node-1 :-

# vim /etc/ha.d/haresources
node-1.unixserveradmin.com    192.168.3.135 httpd

on node-2 :-

# vim /etc/ha.d/haresources
node-2.unixserveradmin.com    192.168.3.135 httpd

Note:- You dont have to create an interface and set this IP or make a IP alias. Heartbeat will take care of it Automatically.

14. Now exchange and save authorized keys between node1 and node2

node-1# ssh-keygen -t rsa

node-1# ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.3.202

node-2# ssh-keygen -t rsa

node-2# ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.3.201

15. Start Heartbeat service on both nodes:

# /etc/init.d/heartbeat start

# chkconfig heartbeat on

Advertisements

March 7, 2012 - Posted by | Apache, Cluster | , , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: