.首先:配置Keepalived信息

 

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,

 

 

 

2.更改配置文件如下:


        (1)ha.d

keepalive 2

deadtime 30

warntime 10

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

Heartbeat+HAproxy_第1张图片

Heartbeat+HAproxy_第2张图片

Heartbeat+HAproxy_第3张图片

Heartbeat+HAproxy_第4张图片

Heartbeat+HAproxy_第5张图片

Heartbeat+HAproxy_第6张图片


.配置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

Heartbeat+HAproxy_第7张图片

Heartbeat+HAproxy_第8张图片



测试结果:(截图)

Heartbeat+HAproxy_第9张图片

Heartbeat+HAproxy_第10张图片

Heartbeat+HAproxy_第11张图片

Heartbeat+HAproxy_第12张图片

Heartbeat+HAproxy_第13张图片