Tuesday, July 28, 2015

Heartbeat Setup - Apache and MySQL

node1 is the host name with IP address of
node2 is the host name with IP address of
virtual IP address is

1. Heartbeat Installation

On both servers:
yum install heartbeat

2. Linux Configuration

On both servers:
a.) vi /etc/hosts
#set the following entries:       localhost    node1   node2
b. save and exit

3. Set the host name of each server:

a.) for
hostname node1
b.) for
hostname node2

4. Set apache configuration

a.) vi /etc/httpd/conf/httpd.conf
b.) save and exit
c.) service httpd restart

5.) Heartbeat Configuration

On both servers:
a.) copy files
cp /usr/share/doc/heartbeat-3.0.4/authkeys /etc/ha.d/
cp /usr/share/doc/heartbeat-3.0.4/ha.cf /etc/ha.d/
cp /usr/share/doc/heartbeat-3.0.4/haresources /etc/ha.d/
b.) vi /etc/ha.d/ha.cf
#set the following entries:
#file to right debug messages to
debugfile /var/log/ha-debug
#file to right other messages to
logfile /var/log/ha-log
#facility to use for syslog () / logger
logfacility     local0
#how long between heartbeats
keepalive 2
#how long to declare host dead
deadtime 10
#how long before issuing “late heartbeat” warning
warntime 10
#very first dead time
initdead 120
#udp port to use for bcast/ucast communication
udpport 694
#what interfaces to broadcast heartbeats over(linux)
bcast eth0
#enable automatic failbacks
auto_failback on
#tell what machines are in the cluster
node node1
node node2
#default gateway;treats as a psuedo-cluster-member
#processes started and stopped with heartbeat
respawn hacluster /usr/lib/heartbeat/ipfail
c.) save and exit
d.) vi /etc/ha.d/haresources
Add the following entry:
d.1.) for node1
node1 IPaddr:: httpd mysqld
d.2.) for node2
node2 IPaddr:: httpd mysqld
d.3.) save and exit
e.) vi /etc/ha.d/authkeys
#set the following entries:
auth 2 
2 crc
e.1.) save and exit
f.) chmod 600 /etc/ha.d/authkeys 
g.) service heartbeat start

No comments:

Post a Comment