这是我们的/etc/haproxy/haproxy.cfg
global
daemon
stats socket /var/lib/haproxy/stats
defaults
maxconn 10000
mode tcp
timeout connect 5s
timeout client 30s
timeout server 30s
listen galera
bind 192.168.55.19:3306
option httpchk
option tcplog
stick on dst
stick-table type ip size 2
timeout client 90m
timeout server 90m
server galera-1 192.168.55.31:3306 check inter 1s port 9200 on-marked-down shutdown-sessions
server galera-2 192.168.55.32:3306 check inter 1s port 9200 on-marked-down shutdown-sessions
server galera-3 192.168.55.33:3306 check inter 1s port 9200 on-marked-down shutdown-sessions
listen monitor
bind 127.0.0.01:9300
mode http
monitor-uri /status
stats enable
stats uri /admin
stats realm Haproxy\ Statistics
stats auth root:Eef7ye9Aeemu7Cei
stats refresh 5s
我们希望只连接到第一个节点 galera-1。galera-2 和 galera-3 应该只是故障转移。
我看到 netstat 有很多连接。为什么?如何排除故障?
# netstat -tupan | grep 192.168.55.32
tcp 0 0 192.168.55.34:59482 192.168.55.32:3306 ESTABLISHED 5045/haproxy
tcp 0 0 192.168.55.34:59466 192.168.55.32:3306 ESTABLISHED 5045/haproxy
tcp 0 0 192.168.55.34:54498 192.168.55.32:3306 ESTABLISHED 5045/haproxy
tcp 0 0 192.168.55.34:45546 192.168.55.32:3306 ESTABLISHED 5045/haproxy
tcp 0 0 192.168.55.34:54430 192.168.55.32:3306 ESTABLISHED 5045/haproxy
tcp 0 0 192.168.55.34:59502 192.168.55.32:3306 ESTABLISHED 5045/haproxy
tcp 0 0 192.168.55.34:59515 192.168.55.32:3306 ESTABLISHED 5045/haproxy
tcp 0 0 192.168.55.34:60039 192.168.55.32:3306 TIME_WAIT -
tcp 0 0 192.168.55.34:59454 192.168.55.32:3306 ESTABLISHED 5045/haproxy
tcp 0 0 192.168.55.34:59523 192.168.55.32:3306 ESTABLISHED 5045/haproxy
tcp 0 0 192.168.55.34:59518 192.168.55.32:3306 ESTABLISHED 5045/haproxy
tcp 0 0 192.168.55.34:59413 192.168.55.32:3306 ESTABLISHED 5045/haproxy