1.yum源安裝
yum -y install heartbeat
更新yum源
yum install epel-release -y
yum源有問題,改用下載rpm包安裝
2.rpm安裝
下載rpm包
heartbeat-3.0.4-2.el6.x86_64.rpm https://pkgs.org/download/heartbeat
heartbeat-libs-3.0.4-2.el6.x86_64.rpm https://pkgs.org/download/libapphb.so.2()(64bit)
安裝rpm包
rpm -ivh heartbeat-3.0.4-2.el6.x86_64.rpm
yum源安裝依賴包
yum -y install PyXML
yum -y install cluster-glue
yum -y install resource-agents
rpm -ivh heartbeat-libs-3.0.4-2.el6.x86_64.rpm heartbeat-3.0.4-2.el6.x86_64.rpm
3.heartbeat配置,詳情https://www.cnblogs.com/liwei0526vip/p/6391833.html
#主節點:192.168.0.204 備節點:192.168.0.205 網關:192.168.0.2
#拷貝三個配置文件至/etc/ha.d/目錄
cd /usr/share/doc/heartbeat-3.0.4/
cp authkeys ha.cf haresources /etc/ha.d/
chmod 600 /etc/ha.d/authkeys #若不設置該權限啟動時會報錯
vi /etc/ha.d/authkeys
#增加以下內容,保存:
auth 3
3 md5 Hello!
vi /etc/ha.d/haresources
#增加以下內容,保存:
oracle11g 192.168.0.206/24/eth0:0 haproxy
#注:hostname vip/掩碼/vip設備名 haproxy為heartbeat監控的服務
vi /etc/ha.d/ha.cf
#增加以下內容,保存:
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 60
udpport 694
ucast eth0 192.168.0.205
auto_failback on
node oracle11g
node haproxy
ping 192.168.0.2
respawn hacluster /usr/lib64/heartbeat/ipfail #注:64位系統為lib64目錄
#將配置拷貝至備節點:
scp authkeys ha.cf haresources root@192.168.0.205:/etc/ha.d
#修改備節點ha.cf配置
ucast eth0 192.168.0.205 修改為 ucast eth0 192.168.0.204
4.啟動heartbeat
service heartbeat start
#先啟主節點,再啟備節點
#若啟動有報錯,根據報錯信息查相應解決方案
5.測試vip漂移
#主節點 ip a
#備節點 ip a
#關掉主節點heartbeat
service heartbeat stop
#vip漂移到備節點