Install Heartbeat HA cluster on Centos

So the backbone of my webcluster i use Heartbeat to monitor the server performance.
Heartbeat is setup to monitor the servers and to take actions if anything happens with some of the nodes.
This guide is for migraing and ip addres from one node to the secondary of the first node goes down.

Then i configure the other servers like apache ore mysql ontop.

First begin to enabling EPEL repos.

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Install heartbeat

yum install heartbeat

Setup so your host fiile is ok

10.20.0.21 web1
10.20.0.22 web2

Create the file /etc/ha.d/ha.cf and ad the following in it

keepalive 2
deadtime 30
bcast eth0
node web1 web2

Create the file vi /etc/ha.d/haresources and ad the following into it

web1 IPaddr::10.0.0.100/24/eth0

 

The ip 10.0.0.100 is the ip that will first be in web1. If web1 goes down the ip will be transfer to web2 that will take over the reqest.

Create the file vi /etc/ha.d/authkeys and fill it with (alter the password)

auth 3
3 md5 password6asd567hajksdhjkhkjjkahdsk

Setting correct chmod to authkeys

chmod 600 /etc/ha.d/authkeys

Copy the config files to your heartbeat nodes. And then restart you heartbeat service

/etc/init.d/heartbeat restart

And run an ifconfig to se where your ip is

ifconfig

And thats it. Now when you first node is down the ip will come up at your secondary server.