Tuesday, July 28, 2015

Heartbeat Setup - Apache and MySQL

Scenario
node1 is the host name with IP address of 192.168.213.232
node2 is the host name with IP address of 192.168.213.235
virtual IP address is 192.168.213.240

1. Heartbeat Installation

On both servers:
yum install heartbeat

2. Linux Configuration

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

3. Set the host name of each server:

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

4. Set apache configuration

a.) vi /etc/httpd/conf/httpd.conf
Listen 192.168.213.240:80
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
ping 192.168.213.255
#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::192.168.213.240/24/eth0 httpd mysqld
d.2.) for node2
node2 IPaddr::192.168.213.240/24/eth0 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