#--------------------------------------------------------------------- # Example configuration for a possible web application. See the # full configuration options online. # # http://haproxy.1wt.eu/download/1.4/doc/configuration.txt # #--------------------------------------------------------------------- #--------------------------------------------------------------------- # Global settings #--------------------------------------------------------------------- global log 127.0.0.1 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 4000 user haproxy group haproxy daemon # turn on stats unix socket stats socket /var/lib/haproxy/stats
#--------------------------------------------------------------------- # common defaults that all the 'listen' and 'backend' sections will # use if not designated in their block #--------------------------------------------------------------------- defaults mode http#mode { tcp|http|health },tcp 表示4层,http表示7层,health仅作为健康检查使⽤ log global option httplog option dontlognull #option http-server-close #option forwardfor except 127.0.0.0/8 #option abortonclose##连接数过⼤⾃动关闭 option redispatch#如果失效则强制转换其他服务器 retries 3#尝试3次失败则从集群摘除 timeout http-request 10s timeout queue 1m #timeout connect 10s #timeout client 1m #timeout server 1m timeout connect 1d#连接超时时间,重要,hive查询数据能返回结果的保证 timeout client 1d#同上 timeout server 1d#同上 timeout http-keep-alive 10s timeout check 10s#健康检查时间 maxconn 3000#最⼤连接数
# 以下为新增内容 listen impalashell bind 0.0.0.0:25003#ha作为proxy所绑定的IP和端⼝ mode tcp#以4层⽅式代理,重要 option tcplog balance roundrobin#调度算法 'leastconn' 最少连接数分配,或者 'roundrobin',轮询分 server impalashell_1 Linux121:21000 check server impalashell_2 Linux122:21000 check server impalashell_3 Linux123:21000 check
listen impalajdbc bind 0.0.0.0:25004#ha作为proxy所绑定的IP和端⼝ mode tcp#以4层⽅式代理,重要 option tcplog balance roundrobin #调度算法 'leastconn' 最少连接数分配,或者 'roundrobin',轮询分 server impalajdbc_1 Linux121:21050 check server impalajdbc_2 Linux122:21050 check server impalajdbc_3 Linux122:21050 check
#--------------------------------------------------------------------- # main frontend which proxys to the backends #--------------------------------------------------------------------- frontend main *:5000 acl url_static path_beg -i /static /images /javascript /stylesheets acl url_static path_end -i .jpg .gif .png .css .js use_backend static if url_static default_backend app