我们有一个HA MariaDB集群,我们的负载平衡器突然开始无法将我们的db节点看作在线。 我们已经更新了我们的应用程序直接击中节点并绕过负载平衡器,因为我们无法弄清楚发生了什么。
haproxyconfiguration
global log 127.0.0.1 local0 log 127.0.0.1 local1 notice #log loghost local0 info maxconn 4096 #debug #quiet user haproxy group haproxy defaults log global mode http retries 3 timeout client 50s timeout connect 5s timeout server 50s option dontlognull option redispatch option tcplog balance roundrobin # Set up application listeners here. listen admin bind 0.0.0.0:22002 mode http stats uri / listen mysql-cluster bind 0.0.0.0:3306 balance roundrobin mode tcp server db1.my-domain.com XX.XX.XXX.94:3306 check server db2.my-domain.com XX.XX.XXX.97:3306 check server db3.my-domain.com XX.XX.XXX.96:3306 check option mysql-check user balance
这个负载平衡器的唯一工作就是平衡数据库节点之间的stream量, 而不是任何其他服务。 我试图启用debugging,以查看更详细的输出,但我找不到任何有关的MySQL集群检查的错误。 在日志中,我将看到与configuration指定的db节点完全无关的日志条目。 这是一个例子:
Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[10] : [ttl=3] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[11] : [auth=1 866db534aa49e7d727e7c41caf33020031f26b0e] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: process_status_message: bad node [prod-load-1] in message Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG: Dumping message with 12 fields Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[0] : [t=status] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[1] : [st=active] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[2] : [dt=1388] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[3] : [protocol=1] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[4] : [src=prod-load-1] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[5] : [(1)srcuuid=0x24deb20(36 27)] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[6] : [seq=a8b208] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[7] : [hg=5792730f] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[8] : [ts=58e3e4fb] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[9] : [ld=0.00 0.01 0.05 1/223 49874] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[10] : [ttl=3] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[11] : [auth=1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: process_status_message: bad node [demo-load2] in message Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG: Dumping message with 10 fields Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[0] : [t=NS_ackmsg] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[1] : [dest=demo-load2] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[2] : [ackseq=2717430] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[3] : [(1)destuuid=0x24e0780(37 28)] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[4] : [src=demo-load2] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[5] : [(1)srcuuid=0x24d5540(36 27)] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[6] : [hg=5391a40d] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[7] : [ts=58e3e4fb] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[8] : [ttl=3] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[9] : [auth=1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: process_status_message: bad node [prod-load-1] in message Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG: Dumping message with 12 fields Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[0] : [t=status] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[1] : [st=active] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[2] : [dt=1388] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[3] : [protocol=1] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[4] : [src=prod-load-1] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[5] : [(1)srcuuid=0x24e0640(36 27)] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[6] : [seq=a8b208] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[7] : [hg=5792730f] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[8] : [ts=58e3e4fb] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[9] : [ld=0.00 0.01 0.05 1/223 49874] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[10] : [ttl=3] Apr 04 18:24:59 database-load-balancer-1 heartbeat: [4048]: ERROR: MSG[11] : [auth=1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
我能做些什么来弄清楚为什么我的数据库节点被列为“下”?
首先,确保您的所有数据库服务器上都有名为“balance”的mysql用户。 然后确保用户“余额”有权从haproxy IP地址连接,而不仅仅是从本地主机。
要configurationhaproxy日志logging,请执行以下操作:
您已经在haproxyconfiguration中为haproxy日志configuration了local0 syslog工具。
... log 127.0.0.1 local0 ...
将其添加到/etc/rsyslog.conf以将日志写入文件。
# provides UDP syslog reception $ModLoad imudp $UDPServerRun 514 # haproxy logs local0.* /var/log/haproxy.log
重新启动haproxy和rsyslog服务,然后检查/var/log/haproxy.log这样的行:
localhost haproxy[1555]: Server mysql/mysql-1 is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
这个日志应该包含足够的信息来查明问题。
您需要使用选项mysql-check和检查,如果您只使用检查MariaDB打开一个连接,并保持打开,直到它超时,你可以很快用完连接。 选项mysql-check会打开和closures连接,但是您需要在数据库中使用可以对数据库进行身份validation的虚拟用户。 您可以检查HAProxy 文档