#########################
######## heartbeat ########
#########################
server4,server5
[root@server4 mnt]# ls
heartbeat-3.0.4-2.el6.x86_64.rpm heartbeat.pdf
heartbeat-devel-3.0.4-2.el6.x86_64.rpm ldirectord-3.9.5-3.1.x86_64.rpm
heartbeat-libs-3.0.4-2.el6.x86_64.rpm
[root@server4 mnt]# yum install heartbeat-* -y
cd /usr/share/doc/heartbeat-3.0.4/
cp ha.cf authkeys haresources /etc/ha.d/
cd /etc/ha.d/
vim authkeys
vim haresources
vim ha.cf
logfacility local0 ##日誌等級,取默認值
keepalive 2 ##心跳頻率,自己設定。1:表示 1 秒;200ms:表示 200 毫秒
deadtime 30 ##節點死亡時間閥值,就是從節點在過了 30 後還沒有收到心跳就認爲主節點死亡,自己設定
warntime 10 ##發出警告時間,自己設定
initdead 60 ##守護進程首次啓動後應該等待 60 秒後再啓動主服務器上的資源
udpport 24 ##心跳信息傳遞的 udp 端口,使用端口 24 進行 bcast 和 ucast 通信 , 取默認值
#baud 19200 #串口波特率,與 serial 一起使用。
#serial /dev/ttyS0 #採用串口來傳遞心跳信息。
bcast eth0 ##採用 udp 廣播播來通知心跳
#ucast eth1 10.0.0.3 #採用網卡 eth1 的 udp 單播來通知心跳,eth1 的 IP
# mcast eth0 225.0.0.1 694 1 0 #採用 udp 多播播來通知心跳
auto_failback on ##當主節點恢復後,是否自動切回
#stonith baytech /etc/ha.d/conf/stonith.baytech #stonith 用來保證共享存儲環境中的數據完整性
#watchdog /dev/watchdog #watchdog 能讓系統在出現故障 1 分鐘後重啓該機器,這個功能可以幫助服務器在確實停止心
跳後能夠重新恢復心跳。 如果使用該特性,修改系統中/etc/modprobe.conf, 添加如下行
options softdog nowayout=0
這樣在系統啓動的時候,在內核中裝入"softdog"內核模塊,用來生成實際的設備文件
/dev/watchdog
node server4 ##主節點名稱,與 uname –n 保持一致。排在第一的默認爲主節點,所以不要搞措順序
node server5 ##副節點名稱,與 uname –n 保持一致
ping 172.25.24.250 #網段
respawn hacluster /usr/lib64/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster
默認 heartbeat 並不檢測除本身之外的其他任何服務,也不檢測網絡狀況。
所以當網絡中斷時,並不會進行 Load Balancer 和 Backup 之間的切換。
可以通過 ipfail 插件,設置'ping nodes'來解決這一問題,但不能使用一個集羣節點作爲
ping 的節點。
chmod 600 authkeys
/etc/init.d/httpd stop
scp ha.cf authkeys haresources server5:/etc/ha.d/
/etc/init.d/heartbeat start
測試:
[root@server4 ha.d]# /etc/init.d/heartbeat stop
[root@server4 ha.d]# /etc/init.d/heartbeat start