linux下heartbeat为LNMP做双机热备

OS:centos 6.5 64位
node1 :192.168.0.155
       10.1.1.2 (心跳)
node2 :192.168.0.156
       10.1.1.3 (心跳)
虚拟IP: 192.168.0.222


1.安装hearbeat软件
yum install epel* -y
yum install heartbeat* -y


2:确保每个节点hosts文件都有条目
192.168.0.155 node1
10.1.1.2 node1
192.168.0.156 node2
10.1.1.3 node2


3:配置authkeys,确保每个节点一致 确保此文件权限为600

cd  /usr/share/doc/heartbeat-3.0.4/
cp ha.cf haresources authkeys /etc/ha.d/

vi authkeys

auth 1
1 crc
#2 sha1 HI!
#3 md5 Hello!

chmod 600 authkeys


4:配置各个节点的ha.cf
node1配置如下:

autojoin    none
debugfile  /var/log/ha-debug     
logfile /var/log/ha-log    
logfacility     local0  
keepalive  2    
deadtime 30   
warntime 10   
initdead  60    
udpport  694   
bcast   eth1    
ucast eth1  10.1.1.3    
auto_failback on    
node    node1    
node    node2

ping 192.168.0.1
respawn hacluster  /usr/lib64/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster

node2配置如下:

autojoin    none
debugfile  /var/log/ha-debug     
logfile /var/log/ha-log    
logfacility     local0  
keepalive  2    
deadtime 30   
warntime 10   
initdead  60    
udpport  694   
bcast   eth1    
ucast eth1  10.1.1.2    
auto_failback on    
node    node1    
node    node2 
ping 192.168.0.1
respawn hacluster  /usr/lib64/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster

5:配置haresource,确保每个节点一致
node1 IPaddr::192.168.0.222/24/eth0 httpd
lnmp必须要是/etc/init.d/里的服务


6:启动Heartbeat

service heartbeat start


7.测试。

1) 拔掉任意一台的业务网卡网线

2) 拔掉任意一台的心跳网卡网线

3) 关闭任意一台机器电源

tcpdump -i all -n -p udp port 694 可以看广播信息,如果用的bcast的话。


如果有多个节点,只需配置一个节点 然后通过 ha_propagate 脚本将配置文件扩散到其他节点。那样的话用mcast比较方便。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值