当通过HAProxy连接到MySQL时错误2013年

我正在尝试使用HAProxy作为2个mysql节点的负载平衡器。 我有HAProxy在3307监听,它将请求路由到3306上的DB。当客户端正在尝试连接到代理(mysql -u … -h .. -P3307 -p …)时,它得到以下错误:

错误2013(HY000):在'读取初始通信数据包'丢失连接到MySQL服务器,系统>错误:0

当客户端试图直接连接到数据库时,它工作正常。 我不知道为什么当通过代理服务器的stream量失败。

这是我已经检查:

  1. /etc/hosts.allow包括“mysqld:ALL:allow”

  2. MySQLconfiguration文件(my.cnf)没有绑定地址行(全部开放)。

我正在使用HAProxy 1.5dev,Mysql 5.1.x,整个enchilada在Amazon linux上运行在ec2上。

这里是HAProxyconfiguration文件:

global log 127.0.0.1 local0 log 127.0.0.1 local1 notice #log loghost local0 info user haproxy group haproxy maxconn 4096 daemon #debug #quiet defaults log global mode tcp option tcplog option dontlognull retries 3 option redispatch maxconn 4096 contimeout 5000 clitimeout 50000 srvtimeout 50000 frontend mysql_cluster bind 10.0.0.150:3307 default_backend mysql_cluster backend mysql_cluster mode tcp balance roundrobin option tcpka option httpchk server lb1 10.0.0.140:3306 check port 9200 inter 5s rise 2 fall 2 server lb2 10.0.0.214:3306 check port 9200 inter 5s rise 2 fall 2 listen stats 10.0.0.150:8081 mode http option httpclose balance roundrobin stats uri / stats realm Haproxy\ Statistics stats auth ***:*** 

有没有人解决过这个问题? 任何想法如何解决这个问题?

任何帮助非常感谢

好的,我解决了。 我的xinetd脚本有问题。

它无法在9200上绑定 – 修复了/ etc / services文件。

谢谢亲爱的,好极了,

HAproxy需要xinetd正确configuration才能正常工作,否则会出现以下错误,

错误2013(HY000):在'读取初始通信数据包'丢失连接到MySQL服务器,系统错误:0

如果已经运行Xinetd将被重新编译。

https://docs.openstack.org/ha-guide/shared-database-manage.html

它通常发生在您的xinetd运行状况检查服务响应错误。
你可以像这样通过telnet来debuggingxinetd

 telnet IPADDR PORT # IPADDR: one of the IPs of your nodes # PORT: the port that node is listening. 

输出告诉你这个问题。