Thursday, October 6, 2011

HeartBeat and build HA (High Availability) cluster environment

This example sets 2 systems as cluster servers. The environment of 2 systems are like below.
They have 2 NICs.
(1) www1.server-linux.info[eth0:192.168.0.21] [eth1:10.0.0.21]
(2) www2.server-linux.info[eth0:192.168.0.22] [eth1:10.0.0.22]

The package Heartbeat:-List of RPM files to download . e.g
1) heartbeat-2.1.3-3.el5.centos.i386.rpm
2) heartbeat-pils-2.1.3-3.el5.centos.i386.rpm
3) heartbeat-stonith-2.1.3-3.el5.centos.i386.rpm


[1]Install HeartBeat first. It's necessary to do this on both systems.

[root@www1 ~]# yum -y install heartbeat

[root@www1 ~]# yum -y install heartbeat
 
# run again becaus of errors

[root@www1 ~]# vi /etc/ha.d/authkey

# create certificates
auth 1
1 crc

[root@www1 ~]# chmod 600 /etc/ha.d/authkeys
 
[2]Config for a server of (1)
 
[root@www1 ~]# vi /etc/ha.d/ha.cf

crm on
# debug log
debugfile /var/log/ha-debug
# log file
logfile /var/log/ha-log
# the way of output to syslog
logfacility local0
# keepalive
keepalive 2
# deadtime
deadtime 30
# deadping
deadping 40
# warntime
warntime 10
# initdead
initdead 60
# port
udpport 694
# interface and IP address of another Host
ucast eth1 10.0.0.22
# auto failback
auto_failback on|off
# node name (the name of "uname -n")
node www1.server-linux.info
node www2.server-linux.info
respawn root /usr/lib/heartbeat/pingd -m 100 -d 5s -a default_ping_set
 
[3]Config for a server of (2). The different point is only the section of ucast.
 
[root@www1 ~]# vi /etc/ha.d/ha.cf

crm on
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
deadping 40
warntime 10
initdead 60
udpport 694
# interface and IP address of another Hostucast eth1 10.0.0.21
auto_failback on
node www1.server-linux.info
node www2.server-linux.info
respawn root /usr/lib/heartbeat/pingd -m 100 -d 5s -a default_ping_set
[4]Start HeartBeat on both server
 
[root@www1 ~]# /etc/rc.d/init.d/heartbeat start
Starting High-Availability services:
[  OK  ]

[root@www1 ~]# chkconfig heartbeat on
[5] Run crm_mon on both server, then if following result is shown, it's OK, heartbeat running normally. These are Basical configuration of HeartBeat.

[root@www1 ~]# crm_mon -i 3

Defaulting to one-shot mode
You need to have curses available at compile time to enable console mode

============
Last updated: Sun Jun 15 05:04:34 2008
Current DC: www2.server-linux.info (f8719a77-70b4-4e5f-851b-dafa7d65d3a2)
2 Nodes configured.
0 Resources configured.
============

Node: www2.server-linux.info (f8719a77-70b4-4e5f-851b-dafa7d65d3a2): online
Node: www1.server-linux.info (2bbd6408-ec01-4b8c-bb8e-207237af3a99): online

No comments:

Post a Comment