Mysql-Proxy 不会进行故障转移(?)
这是我第一次使用 mysql-proxy,我遇到了奇怪的行为,我想知道社区以前是否已经解决过这个问题。
我有 mysql-proxy (0.8.2) 在 amazon linux (在 ec2 中) 上运行,连接到 2 个 mysql 服务器。我的 java 客户端可以连接到代理并且负载平衡工作正常。
我的问题是这样的:我有一个客户端(通过代理)连接到服务器 A。在我测试故障转移之前它工作得很好。当我关闭服务器 A 并且客户端尝试执行简单的插入命令(在已建立的连接上)时,我期望代理将请求重定向到服务器 B。但是我收到此异常:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
:通信链路故障。
本例中的客户端是一个使用 mysql-connector-java-5.1.17-bin.jar 的 Java 程序
有什么想法如何解决这个问题还是我在这里遗漏了任何东西?
This is the first time I am using mysql-proxy and I am experiencing the weird behavior I was wondering if the community has tackled it before.
I have mysql-proxy (0.8.2) running on amazon linux (in ec2) connected to 2 mysql servers. My java client can connect to the proxy and load balancing works fine.
My problem is this: I have a client that is connected (via the proxy) to a server A. It works great until i test the fail-over. When I close server A and the client tries to execute simple insert command (on an already established connection), I was expecting the proxy to redirect the request to server B. However I am getting this exception:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
: Communications link failure.
The client in this case is a Java program using mysql-connector-java-5.1.17-bin.jar
Any ideas how to solve this or am I missing anything here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是有关此问题的更新,以防其他人遇到同样的问题。
当客户端连接到后端服务器时,mysql-proxy 似乎会检查后端服务器的状态。它不会与数据库执行任何保活\心跳。我曾尝试使用 lua 脚本强制执行此类行为,但惨败。
一个潜在的替代方案可能是使用 HAProxy 并包含 xinted mysqlchecks。我个人没有尝试过。我们最终可能会构建一个代理连接客户端,它将包装 java.sql.Connection 并与 mysql-proxy 进行适当的交互。
如果您找到其他方法来实现上述目标,请告诉我。
Here's an update on this issue, in case some else has the same problem.
It seems that mysql-proxy checks the status on the back-end server when the client connects to it. It doesn't perform any keepalive\heartbeat with the DBs. I have tried to force such behavior using lua scripts but failed miserably.
A potential alternative might be to use HAProxy and include xinted mysqlchecks. I haven't tried it personally. We'll probably end up building a proxy connection client that will wrap java.sql.Connection and will interact with mysql-proxy appropriately.
Let me know if you found other ways to achieve the above.