一.首先:配置Keepalived信息node
1.下載 安裝web
heartbeat-3.0.4-2.el6.x86_64.rpm,api
heartbeat-devel-3.0.4-2.el6.x86_64.rpm,cookie
heartbeat-libs-3.0.4-2.el6.x86_64.rpm,app
2.更改配置文件以下:ide
(1)ha.d測試
keepalive 2ui
deadtime 30spa
warntime 10server
initdead 60
udpport 1145
bcast eth0
...
node server1.example.com
node server4.example.com
ping 172.25.254.250
...
respawn hacluster /usr/lib64/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster
(2)haresources
server1.example.com IPaddr::172.25.254.168/24/eth0 haproxy
(3)authkeys
auth 1
1 crc
二.配置haproxy信息
1.下載安裝haproxy
2.更改配置文件信息以下(haproxy.cfg)
[標號]
26log 127.0.0.1 local2
28 chroot /var/lib/haproxy
29 pidfile /var/run/haproxy.pid
30 maxconn 4000
31 user haproxy
32 group haproxy
33 daemon
...
42defaults(默認值不用改)
(末尾自定義信息)
listen admin *:8080
stats enable
stats uri /status
stats auth admin:redhat
stats refresh 5s
listen hxl *:80
balance roundrobin
server web1 172.25.254.162:80 cookie applinst1 check inter 2000 rise 2 fall 5
server web2 172.25.254.163:80 cookie applinst2 check inter 2000 rise 2 fall 5
測試結果:(截圖)