welcome to netwrkspider

Monday, June 17, 2013

How to : Install & configure High Availbility Heartbeat Cluster on Centos 6.x/ Redhat 6.x with Apache web Server

Heartbeat is a daemon that provides cluster infrastructure (communication and membership) services to its clients. This allows clients to know about the presence (or disappearance!) of peer processes on other machines and to easily exchange messages with them.
In order to be useful to users, the Heartbeat daemon needs to be combined with a cluster resource manager (CRM) which has the task of starting and stopping the services (IP addresses, web servers, etc.) that cluster will make highly available. Pacemaker is the preferred cluster resource manager for clusters based on Heartbeat. Source : http://linux-ha.org/wiki/Heartbeat

Requirements :-
2 linux nodes, RHEL 6.x/CentOS 6.x
LAN & Internet connection.
A yum server.
Node-1: 192.168.28.4
Node-2: 192.168.28.5
Virtaul IP Address (VIP) :-  192.168.28.6
1. Set the fully qualified hostnames and give corresponding entries in /etc/hosts and /etc/sysconfig/network
node-1 :- 192.168.28.4 :- node1
node-2 :- 192.168.28.5 :- node2

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.28.6: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. (If You are on terminal use Lynx browser )

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/
(Note : Add latest EPEL repository )

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@net4
#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 2
deadtime 30
warntime 10
initdead 120
udpport 694
bcast eth0
auto_failback on //Keep resources on their "preferred" hosts - needed for active/active
node node1 // in both nodes command “uname -n” should give the these hostnames
node node2
—————————————–

13. We have to edit the haresources file on both nodes separately:
on node-1 :-
# vim /etc/ha.d/haresources
node1    192.168.28.6 httpd
on node-2 :-
# vim /etc/ha.d/haresources
node2    192.168.28.6 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 node2
node-2# ssh-keygen -t rsa
node-2# ssh-copy-id -i ~/.ssh/id_rsa.pub node1
15. Start Heartbeat service on both nodes:
# /etc/init.d/heartbeat start
# chkconfig heartbeat on

3 comments:

Anonymous said...

Every weekend i used to go to see this site, because i
want enjoyment, for the reason that this this website conations truly fastidious funny material too.



Have a look at my blog: home income

Goi said...

Hi, Do you have a guide for CentOS 7? I've added the EPEL repo for CentOS 7 but heartbeat doesn't seem to exist there.

Pinnacle Mobile said...

Hi,

Nice tutorial.. I have an issue, when i try starting heartbeat on node1 and node2, I see it says

[root@node1 ~]# /etc/init.d/heartbeat start
Starting High-Availability services: ERROR: Unable to find nic or netmask.
INFO: [findif] failed
INFO: Resource is stopped
Done.

[root@node1 ~]#

When I check on heartbeat status, i see it says it's running and when i check on log, I see it started. Am kind stuck here, please I need help on how to go about this.