集羣基礎------(heartbeat心跳組件)

集羣間心跳(heartbeat)

1.下載安裝心跳組件&—兩個節點均要安裝

    heartbeat-3.0.4-2.el6.x86_64.rpm
    heartbeat-devel-3.0.4-2.el6.x86_64.rpm
    heartbeat-libs-3.0.4-2.el6.x86_64.rpm
yum install -y heartbeat-*

2.修改heartbeat配置文件(heartbeat沒有健康檢查)
cd /etc/ha.d/

1)查看配置定義:
[root@server1 ha.d]# cat README.config
You need three configuration files to make heartbeat happy,
and they all go in this directory.

They are:
    ha.cf       Main configuration file(主配置文件)
    haresources Resource configuration file(資源定義文件)
    authkeys    Authentication information(認證文件)

These first two may be readable by everyone, but the authkeys file
must not be.

The good news is that sample versions of these files may be found in
the documentation directory (providing you installed the documentation).

If you installed heartbeat using rpm packages then
this command will show you where they are on your system:
        rpm -q heartbeat -d

If you installed heartbeat using Debian packages then
the documentation should be located in /usr/share/doc/heartbeat

[root@server1 ha.d]# cd /usr/share/doc/heartbeat-3.0.4/
[root@server1 heartbeat-3.0.4]# ls
apphbd.cf  ChangeLog     ha.cf
authkeys   COPYING       haresources
AUTHORS    COPYING.LGPL  README

2)複製主配置文件到/etc/ha.d/才能生效

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

3)修改主配置文件(在主節點修改)
cd /etc/ha.d/

    vim ha.cf   (調用ipfaill插件用於主備切換,實現高可用)

34 logfacility     local0
48 keepalive 2      心跳頻率
56 deadtime 30      多久一次判斷是否掛了
61 warntime 10      多久警告一次
71 initdead 60      初始化時間
76 udpport 733      端口連接(局域網不能衝突了)
91 bcast   eth0     廣播發送
157 auto_failback on    自動回切
211 node    server1
212 node    server4
220 ping 172.25.39.250(和227行的ping羣設定一個即可)
253 respawn hacluster /usr/lib64/heartbeat/ipfail(64位)
259 apiauth ipfail gid=haclient uid=hacluster(api認證,在裝rpm包時候,用戶已經被創建)

4)修改認證文件
cd /etc/ha.d/

    vim authkeys
23 auth 1
24 1 crc

       chmod 600 authkeys (認證key必須600權限,不然訪問不了)*

5)修改資源定義文件
cd /etc/ha.d/(可以自動搜索這三個地方的腳本/etc/ha.d/rc.d/、/etc/ha.d/resourced)

    vim haresources
151 server1 IPaddr::172.25.39.100/24/eth0 httpd(IPaddr:資源腳本名;後面傳參)(eth0:vip生效的地方)【主節點的主機名、vip、需要維護的服務】

3.發送相同的三個文件到server4

    scp ha.cf authkeys haresources server4:/etc/ha.d/

4.
1)/etc/init.d/heartbeat start(server1)
tail -f /var/log/messages(查看是否有錯誤)
2)開啓server4上的心跳

5.測試:

編寫測試頁:/var/www/html/index.html
    (/etc/init.d/heartbeat stop
    /etc/init.d/heartbeat start)
可以在網頁上測試172.25.78.100或者在主機上 curl 172.25.78.100
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章