通过 HAProxy 连接到 mysql 时出现 ERROR 2013

A.R*_*.RG 5 mysql haproxy

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

错误 2013 (HY000):在“读取初始通信数据包”时失去与 MySQL 服务器的连接,系统 > 错误:0

当客户端尝试直接连接到数据库时,它工作正常。我不知道为什么当流量通过代理时它会失败。

这是我已经检查过的:

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

  2. MySQL 配置文件 (my.cnf) 没有绑定地址行(对所有人开放)。

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

这是 HAProxy 配置文件:

    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 ***:***
Run Code Online (Sandbox Code Playgroud)

以前有人解决过这个问题吗?任何想法如何解决这个问题?

非常感谢任何帮助

A.R*_*.RG 2

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

它无法绑定到 9200 - 在 /etc/services 文件中修复它。