标签:haproxy
最近公司的IIS服务器总是宕机,自己对运维知识又很欠缺,听了一些介绍决定硬着头皮上,架设一个haproxy负载到后端两个IIS.这里总结一下经验吧!
首先用yum命令安装haproxy这个很简单,说一下流程吧!先安装gcc编译器
# yum install gcc
# wget http://haproxy.1wt.eu/download/1.4/src/ haproxy-1.4.24.tar.gz
# tar zxvf haproxy-1.4.24
# make install
# mkdir -p /usr/local/haproxy/etc
# mkdir -p /usr/local/haproxy/sbin
# cp examples/haproxy.cfg /usr/local/haproxy/etc
# ln -s /usr/local/sbin/haproxy /usr/local/haproxy/sbin/haproxy
到这里安装的步骤就基本完成了,下面开始要进行配置文件的修改,在网上找了许多文件尝试不成功,最后找到了一篇博文用ACL的方式配置成功,自己也不理解具体的含义。姑且用自己的理解先做着吧!
global log 127.0.0.1 local0 log 127.0.0.1 local1 notice #log loghost local0 info maxconn 50000 #最大连接5W不知道针对什么设备而言 chroot /usr/share/haproxy uid 99 gid 99 daemon #debug #quiet
defaults log global mode http option httplog option redispatch option abortonclose retries 3 maxconn 50000 #最大连接10W不知道针对什么设备而言 contimeout 5000 clitimeout 50000 srvtimeout 50000 frontend WEB_SITE bind 0.0.0.0:80 mode http log global maxconn 100000 option httplog option httpclose option forwardfor acl WEB1 hdr_reg(host) -i ^(gq.wdmmo.com)#gq域名主机头赋值给WEB1 acl WEB2 hdr_reg(host) -i ^(passport.wdmmo.com) acl WEB3 hdr_reg(host) -i ^(pay.wdmmo.com) acl WEB4 hdr_reg(host) -i ^(op.wdmmo.com) acl WEB5 hdr_reg(host) -i ^(yx.wdmmo.com) use_backend WEB1_SER if WEB1 #WEB1使用后端服务器WEB1_SER use_backend WEB2_SER if WEB2 use_backend WEB3_SER if WEB3 use_backend WEB4_SER if WEB4 use_backend WEB5_SER if WEB5 default_backend web_server backend WEB1_SER mode http balance roundrobin #轮询负载,各服务器同等数量负载 cookie SERVERID insert nocache indirect server server1 192.168.10.53:80 cookie 11 check inter 1500 rise 3 fall 3 weight 1 #gq一个服务器真是内网地址,参数作用不明 server server2 192.168.10.131:80 cookie 11 check inter 1500 rise 3 fall 3 weight 1 backend WEB2_SER mode http balance roundrobin cookie SERVERID insert nocache indirect server server1 192.168.10.53:80 cookie 11 check inter 1500 rise 3 fall 3 weight 1 server server2 192.168.10.131:80 cookie 11 check inter 1500 rise 3 fall 3 weight 1 backend WEB3_SER mode http balance roundrobin cookie SERVERID insert nocache indirect server server1 192.168.10.53:80 cookie 11 check inter 1500 rise 3 fall 3 weight 1 server server2 192.168.10.131:80 cookie 11 check inter 1500 rise 3 fall 3 weight 1 backend WEB4_SER mode http balance roundrobin cookie SERVERID insert nocache indirect server server1 192.168.10.53:80 cookie 11 check inter 1500 rise 3 fall 3 weight 1 server server2 192.168.10.131:80 cookie 11 check inter 1500 rise 3 fall 3 weight 1 backend WEB5_SER mode http balance roundrobin cookie SERVERID insert nocache indirect server server1 192.168.10.53:80 cookie 11 check inter 1500 rise 3 fall 3 weight 1 server server2 192.168.10.131:80 cookie 11 check inter 1500 rise 3 fall 3 weight 1 backend web_server mode http balance roundrobin cookie SERVERID insert nocache indirect server server1 192.168.10.53:80 cookie 11 check inter 1500 rise 3 fall 3 weight 1 server server2 192.168.10.131:80 cookie 11 check inter 1500 rise 3 fall 3 weight 1 listen admin_stats bind 192.168.10.57:1080 mode http maxconn 10 stats uri /stats stats auth wd1023:wd!023 stats hide-version
本文出自 “颜色” 博客,谢绝转载!
还不熟悉Linux系统安装haproxy的记录!,布布扣,bubuko.com
标签:haproxy
原文地址:http://mgnetyse.blog.51cto.com/8971272/1426759