内容发布更新时间 : 2024/12/22 17:22:45星期一 下面是文章的全部内容请认真阅读。
cd /apps
tar zxvf haproxy-1.4.24.tar.gz --解压haproxy
tar zxvf keepalived-1.2.12.tar.gz --解压keepalived
cd keepalived-1.2.12
//先安装gcc yum install gcc*,openssl*
//yum install openssl-devel
ln -s /usr/src/kernels/2.6.9-78.EL-i686/usr/src//linux
./configure
make && make install
cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived
cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/sbin/keepalived /usr/sbin/
--chkconfig keepalived on --配置自动启动 service keepalived start
[root@fzjh01 ~]# vi /etc/keepalived/keepalived.conf global_defs {
router_id haproxy-1 }
vrrp_script check_nginx {
script \interval 2
weight 2 }
vrrp_instance VI_1 { state MASTER interface eth0
virtual_router_id 51 priority 180 #100 advert_int 1 authentication { auth_type PASS auth_pass 1234 }
track_script { check_nginx }
virtual_ipaddress {
10.172.0.108/24 dev eth0 } }
tar xzvf haproxy-1.4.24.tar.gz cd /apps/haproxy-1.4.24
make TARGET=linux26 PREFIX=/usr/local/haproxy make install PREFIX=/usr/local/haproxy
mkdir /usr/local/haproxy/conf -p
[root@fzjh01 ~]# vi /usr/local/haproxy/conf/haproxy.cfg global
log 127.0.0.1 local0
# log 127.0.0.1 local1 notice maxconn 32000 # user haproxy # group haproxy daemon # nbproc 4
defaults log global mode http
# option httplog option dontlognull retries 3
option redispatch maxconn 32000 contimeout 30000 clitimeout 500000 srvtimeout 500000
#FOR ADMIN
listen admin_stat bind *:8088 stats enable
# stats hide-version stats uri /lb_status
# stats realm Haproxy\\ statistics # stats auth sxit:sxit stats refresh 20s stats admin if TRUE
#FOR HIS
listen his_8080 *:8080 balance roundrobin
cookie SERVERID insert nocache indirect
option httpchk HEAD /xtHisService/index.jsp HTTP/1.0 option forwardfor
server 10.172.0.36-8080 10.172.0.36:8080 cookie his01 check weight 10 server 10.172.0.39-8080 10.172.0.39:8080 cookie his02 check weight 10
#FOR EMR
listen emr_8081 bind *:8081
balance roundrobin
cookie SERVERID insert nocache indirect option httpchk HEAD / HTTP/1.0 option forwardfor
server 10.172.0.42-8081 10.172.0.42:8081 cookie emr01 check weight 10 server 10.172.0.43-8081 10.172.0.43:8081 cookie emr02 check weight 10
#FOR UDP
listen udp_80 bind *:80
balance roundrobin