CentOS HeartBeat 配置

Standard

Gateway:192.168.0.1
A:
eth0:192.168.0.216
eth0:0: 192.168.0.210
eth1:10.0.0.216
hostname:svr1
B:
eth0:192.168.0.217
eth0:0: 192.168.0.210
eth1:10.0.0.217
hostname:svr2

A:
vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.0.216 srv1 HA01
10.0.0.216 HA01
10.0.0.217 HA02
192.168.0.217 svr2

B:
vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.0.217 srv2 HA02
10.0.0.217 HA02
10.0.0.216 HA01
192.168.0.216 svr1

—————————————
A & B:
vi /etc/rc.local
ipvsadm -A -t 192.168.0.210:80 -s rr
ipvsadm -a -t 192.168.0.210:80 -r 192.168.0.216:80 -m
ipvsadm -a -t 192.168.0.210:80 -r 192.168.0.217:80 -m

yum -y install heartbeat
cd /usr/share/doc/heartbeat-2.1.3/
cp authkeys ha.cf haresources /etc/ha.d/

—————————————
A:
cd /etc/ha.d/
vi authkeys

auth 1
1 crc

chmod 600 authkeys

vi ha.cf
logfile /var/log/ha_log/ha-log.log
bcast eth1
keepalive 2 # 2 seconds or keepalive 100ms
warntime 10
deadtime 30
initdead 120
hopfudge 1
udpport 694
auto_failback on
node svr1
node svr2
ping 192.168.0.1
respawn root /usr/lib/heartbeat/ipfail
apiauth ipfail gid=root uid=root

vi haresources
svr1 IPaddr::192.168.0.210 ipvsadm httpd

B:
cd /etc/ha.d/
vi authkeys

auth 1
1 crc

chmod 600 authkeys

vi ha.cf
logfile /var/log/ha_log/ha-log.log
bcast eth1
keepalive 2
warntime 10
deadtime 30
initdead 120
hopfudge 1
udpport 694
auto_failback on
node svr1
node svr2
ping 192.168.0.1
respawn root /usr/lib/heartbeat/ipfail
apiauth ipfail gid=root uid=root

vi haresources
svr2 IPaddr::192.168.0.210 ipvsadm httpd
—————————————
A & B:
Service heartbeat start
Service httpd start

http对外访问IP:192.168.0.210

转载请注明出处:http://yemaosheng.com

2 thoughts on “CentOS HeartBeat 配置

  1. 小白

    在机器B的haresources配置文件中,为什么网上其他人都说应该和机器A的一样,写成
    svr1 IPaddr::192.168.0.210 ipvsadm httpd
    这种形式呢!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.