这是我们的/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
答案 0 :(得分:1)
失败
如果您希望galera-2
和galera-3
仅进行故障转移,请将backup
关键字添加到其server
行。
多重连接
对我来说很正常。这些可能由您的MySQL客户端或连接到数据库的应用程序打开。要确认这些连接的用途,您可以使用Wireshark(从客户端运行)或tcpdump
(来自服务器)等数据包嗅探器。
有关您的设置的一些评论: