linux之heartbeat高可用的简单配置
Heartbeat
系統環境:
防火墻關閉,
seliux狀態為disabled
各服務器之間組做好地址解析
Node3:172.25.44.3
Node4:172.25.44.4
物理真機:172.25.44.250
VIP:172.25.44.100
?
以下內容node3和nod4上都進行配置
?
安裝軟件
heartbeat-libs-3.0.4-2.el6.x86_64.rpm
heartbeat-3.0.4-2.el6.x86_64.rpm ???????
ldirectord-3.9.5-3.1.x86_64.rpm
heartbeat-devel-3.0.4-2.el6.x86_64.rpm
rpm -q heartbeat -d???????????? ##查看軟件生成的配置文件
?
cd /usr/share/doc/heartbeat/
cp ha.cf haresources authkeys /etc/ha.d
1).
vim?/etc/ha.d/ha.cf????? ####需要添加或更改的內容,根據具體情況而設定,參數不固定
29 logfile /var/log/ha-log
48 keepalive 2
56 deadtime 30
61 warntime 10
71 initdead 60
76 udpport 738
91 bcast ??eth0
157 auto_failback on
211 node ???server3.example.com
212 node ???server4.example.com
220 ping 172.25.44.250 ?#已存在的ip地址,非節點地址,
253 respawn hacluster /usr/lib64/heartbeat/ipfail
259 apiauth ipfail gid=haclient uid=hacluster
#########################################
主配置文件(/etc/ha.d/ha.cf):
debugfile /var/log/ha-debug
調試日志文件文件,取默認值
logfile /var/log/ha-log
系統運行日志文件,取默認值
logfacility local0
日志等級,取默認值
keepalive 2
心跳頻率,自己設定。1:表示 1 秒;200ms:表示 200 毫秒
deadtime 30
節點死亡時間閥值,就是從節點在過了 30 后還沒有收到心跳就認為主節點死亡,自己設定
warntime 10
發出警告時間,自己設定
initdead 120
守護進程首次啟動后應該等待 120 秒后再啟動主服務器上的資源
udpport 694
心跳信息傳遞的 udp 端口,使用端口 694 進行 bcast 和 ucast 通信,取默認值
#baud 19200
串口波特率,與 serial 一起使用。
#serial /dev/ttyS0
采用串口來傳遞心跳信息。
bcast eth1
采用 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 station3.example.com
主節點名稱,與 uname –n 保持一致。排在第一的默認為主節點,所以不要搞措順序
node station4.example.com
副節點名稱,與 uname –n 保持一致
ping 192.168.0.254
respawn hacluster /usr/lib/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster
默認 heartbeat 并不檢測除本身之外的其他任何服務,也不檢測網絡狀況。
所以當網絡中斷時,并不會進行 Load Balancer 和 Backup 之間的切換。
可以通過 ipfail 插件,設置'ping nodes'來解決這一問題,但不能使用一個集群節點作為ping 的節點。
###########################
2).
vim /etc/ha.d/haresources
server3.example.com IPaddr::172.25.44.100/24/eth0 httpd
虛擬ip是172.25.44.100,啟動服務是httpd
########################
資源文件(/etc/ha.d/haresources):
station3.example.com IPaddr::192.168.0.200/24/eth0 ldirectord httpd
這個文件中定義了實現集群所需的各個軟件的啟動腳本,這些腳本必須放在/etc/init.d 或者/etc/ha.d/resource.d 目錄里 IPaddr 的作用是啟動 Virutal IP,它是 HeartBeart 自帶的一個腳本;ldirectord 的作用是啟動 ldirectord 監控程序,它會使 ldirectord.cf 中定義的 lvs 生效,
并監聽其健康狀;httpd 是 apache 服務的啟動腳本.
3).
vim /etc/ha.d/authkeys
chmod 600 /etc/ha.d/authkeys
配置完成后將文件傳送到node4
#scp ha.cf haresources authkeys 172.25.44.4:/etc/ha.d/
#########認證文件,此文件權限必須是600#######
?
測試:
1..編寫測試文件(在node3和node4上編寫不同內容方便測試)
?vim /var/www/html/index.html
2.#?/etc/init.d/heartbeat start? ###l兩邊都開啟hearbeat服務
Starting High-Availability services: INFO: ?Resource is stopped
Done.
#arp -an | grep 172.25.44.100 ?##查看vip在哪個節點上運行(在物理真機上執行此命令)
在主節點上查看vip
#ip addr show
3.瀏覽器訪問vip:172.25.44.100,查看網頁內容
4.Node3上手動關閉heartbeat服務,查看vip是否跳轉到node4上,同時httpd在node4上開啟,訪問172.25.44.100,若內容與節點node4上測試文件內容一致,測試成功。
?
轉載于:https://blog.51cto.com/65147718/1864791
總結
以上是生活随笔為你收集整理的linux之heartbeat高可用的简单配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 从JVM指令层面看try-catch-f
- 下一篇: 支付宝支付后回调通知中responseT