首页 > 网络 > 其他 >

Haporxy 负载均衡配置-李世龙-51CTO博客

2019-11-22

vim? etc haproxy haproxy cfg global ????log?????????127 0 0 1?local2????chroot?????? var lib haproxy ????pidfile????? var run haproxy pid ????maxconn?????4000 ????user????????haproxy ????group???

vim?/etc/haproxy/haproxy.cfg
global
????log?????????127.0.0.1?local2????chroot??????/var/lib/haproxy
????pidfile?????/var/run/haproxy.pid
????maxconn?????4000
????user????????haproxy
????group???????haproxy
????daemon
????stats?socket?/var/lib/haproxy/stats

defaults
????mode????????????????????http
????log?????????????????????global
????option??????????????????httplog
????option??????????????????dontlognull
????option?http-server-close
????option?forwardfor???????except?127.0.0.0/8
????option??????????????????redispatch
????retries?????????????????3????timeout?http-request????10s????timeout?queue???????????1m????timeout?connect?????????10s????timeout?client??????????1m????timeout?server??????????1m????timeout?http-keep-alive?10s????timeout?check???????????10s
????maxconn?????????????????3000

frontend??main?*:80
????use_backend?webserver?

frontend??stats_ser??#定义stats前端
????bind?*:8800??????#定义stats监听端口
????use_backend?web_stats

backend?webserver
????balance????roundrobin?
????cookie?WEBSVR?insert?nocache?
????server??web1?192.168.199.126:80?weight?1?maxconn?500?maxqueue?300?cookie?cklser1?check?
????server??web2?192.168.199.194:80?weight?1?maxconn?500?maxqueue?300?cookie?cklser2?check?
????server??web3?192.168.199.180:80?weight?1?maxconn?500?maxqueue?300?cookie?cklser3?check?

backend?web_stats
????server?web1?192.168.199.126:80?check
????server?web2?192.168.199.194:80?check
????server?web3?192.168.199.180:80?check
????stats?enable???#开启stats功能
????stats?hide-version?#隐藏haproxy版本信息,有益于安全
????#stats?scope???.???#作用当前域
????stats?uri?????/ckl?stats??#stats页面的uri
????stats?realm???Haproxy\?Statistics??#备注信息
????stats?auth????ckl:1QAZnji9??#用户名密码
????stats?auth????zld:4rfvBHU8??#用户名密码
????stats?auth????admin:7uj4rf99??#用户名密码
????stats?admin?if?TRUE?#不添加此项,则不开启管理员功能
????stats?refresh?5s?#页面刷新间隔

10.2.重新加载服务

systemctl?restart?haproxy.service

10.3.测试状态页面:

wKioL1ht5_2SmRNGAAA7cir4J6A090.png-wh_50

wKioL1hvP4Cw1MkBAAGAL8i-joU048.png-wh_50

相关文章
最新文章
热点推荐