master配置node
[root@localhost ~]# yum install -y epel-releasenginx
[root@localhost ~]# yum install -y heartbeatssh
[root@localhost ~]# yum install -y libnetide
[root@localhost ~]# yum install -y openssh-clientsspa
[root@localhost ~]# vi /etc/hosts 增長如下內容debug
192.168.10.29 master日誌
192.168.10.39 slaveorm
[root@localhost ~]# cp /usr/share/doc/heartbeat-3.0.4/authkeys /usr/share/doc/heartbeat-3.0.4/ha.cf /usr/share/doc/heartbeat-3.0.4/haresources /etc/ha.d/ip
[root@localhost ~]# vi /etc/ha.d/authkeysmd5
auth 3
3 md5 Hello!
[root@localhost ~]# chmod 600 /etc/ha.d/authkeys
[root@localhost ~]# vi /etc/ha.d/haresources
# 這裏的192.168.10.111 是vip,即虛擬ip
master 192.168.10.111/24/eth0:0 nginx
[root@localhost ~]# vi /etc/ha.d/ha.cf
# 錯誤日誌
debugfile /var/log/ha-debug
# 正常日誌
logfile /var/log/ha-log
# 日誌級別
logfacility local0
# 探測間隔時間,2秒
keepalive 2
# 30秒ping不通,認爲冗機
deadtime 30
# 10秒ping不通,發出警告
warntime 10
# 預防對方在重啓
initdead 60
# 監聽端口
udpport 694
# slave的IP
ucast eth0 192.168.10.29
# 假設slave正在工做,master已正常啓動,則自動切換回master
auto_failback on
# 節點
node master
node slave
# 仲裁IP
ping 192.168.10.1
respawn hacluster /usr/lib/heartbeat/ipfail
從master端拷貝配置文件到slave
[root@localhost ~]# scp /etc/ha.d/authkeys /etc/ha.d/ha.cf /etc/ha.d/haresources slave:/etc/ha.d/
[root@localhost ~]# /etc/init.d/heartbeat start
slave配置
[root@localhost ~]# yum install -y epel-release
[root@localhost ~]# yum install -y heartbeat
[root@localhost ~]# yum install -y libnet
[root@localhost ~]# yum install -y openssh-clients
[root@localhost ~]# vi /etc/hosts 增長如下內容
192.168.10.29 master
192.168.10.39 slave
[root@localhost ~]# vi /etc/ha.d/ha.cf
# 錯誤日誌
debugfile /var/log/ha-debug
# 正常日誌
logfile /var/log/ha-log
# 日誌級別
logfacility local0
# 探測間隔時間,2秒
keepalive 2
# 30秒ping不通,認爲冗機
deadtime 30
# 10秒ping不通,發出警告
warntime 10
# 預防對方在重啓
initdead 60
# 監聽端口
udpport 694
# master的IP
ucast eth0 192.168.10.39
# 假設slave正在工做,master已正常啓動,則自動切換回master
auto_failback on
# 節點
node master
node slave
# 仲裁IP
ping 192.168.10.1
respawn hacluster /usr/lib/heartbeat/ipfail
[root@localhost ~]# /etc/init.d/heartbeat start
至此,HA(high available)集羣配置完畢