使用 HaProxy 进行负载均衡,HAProxy搭建步骤,参考
https://blog.csdn.net/qq_26412535/article/details/115801038
vim /usr/local/haproxy-2.0.8/conf/haproxy.cfg
配置文件参考:
global
log 127.0.0.1 local0
maxconn 1000
daemon
defaults
log global
mode tcp
option tcplog
option dontlognull
retries 3
timeout connect 5000
timeout client 50000
timeout server 50000
listen admin_stats
bind 0.0.0.0:1080
mode http
option httplog
maxconn 10
stats refresh 30s
stats uri /stats
stats realm XingCloud\ Haproxy
stats auth admin:admin
stats auth cat:cat
stats hide-version
stats admin if TRUE
listen mycat_cluster
bind 0.0.0.0:8096
mode tcp
balance roundrobin
server mycat_01 192.168.197.128:8066 check inter 5000 rise 2 fall 3
server mycat_02 192.168.197.130:8066 check inter 5000 rise 2 fall 3
server mycat_03 192.168.197.131:8066 check inter 5000 rise 2 fall 3
timeout server 20000
listen mycat_admin
bind 0.0.0.0:8097
mode tcp
balance roundrobin
server mycat_01 192.168.197.128:9066 check inter 5000 rise 2 fall 3
server mycat_02 192.168.197.130:9066 check inter 5000 rise 2 fall 3
server mycat_03 192.168.197.131:9066 check inter 5000 rise 2 fall 3
timeout server 20000
启动haproxy
/usr/local/haproxy-2.0.8/sbin/haproxy -f /usr/local/haproxy-2.0.8/conf/haproxy.cfg
访问统计页面
http://192.168.197.128:1080/stats (haproxy)