具有故障转移功能的 Mysql 连接池

发布于 2024-12-20 00:14:54 字数 240 浏览 3 评论 0原文

问题一: 我正在使用 MySQL Connector /J 连接到 MySQL。我正在为每个请求创建连接。我需要使用连接池。我是否需要选择 c3p0 或者我可以使用连接器库提供的​​ MysqlConnectionPool 类。

问题2: 我可能需要在两个 MySQL 数据库服务器之间进行负载平衡/故障转移。我可以使用 jdbc:mysql://host,host2/dbname 自动执行故障转移。我想结合使用连接池和故障转移。我应该如何实现它。

Question 1:
I am using MySQL Connector /J to connect to MySQL. I am creating connection for every request. I need to use connection pool. Whether i need to choose c3p0 or i could use MysqlConnectionPool class provided by the connector library.

Question 2:
I may need to load balace / failover between two MySQL database servers. I could use jdbc:mysql://host,host2/dbname to do the failover automatically. I want to use connection pool and failover in combination. How should i acheive it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世界和平 2024-12-27 00:14:54

我建议使用 C3PO 或其他东西。它将更好地集成到 Java EE 应用服务器中,并且与数据库无关。

你的第二个问题要复杂得多。负载平衡通常通过位于客户端和负载平衡实例之间的某种设备(例如 F5 或 ACE)来完成。你就是这样做的吗?如果您在两者之间进行负载平衡,您打算如何保持数据同步?如果连接不是“粘性”的,您将期望在两个实例中找到插入的数据。

也许这个参考可以帮助您开始:

http://www.howtoforge.com/loadbalanced_mysql_cluster_debian

I'd recommend using C3PO or something else. It'll integrate into a Java EE app server better, and it's database agnostic.

Your second question is a good deal more complicated. Load balancing is usually done with an appliance of some kind, like an F5 or ACE, that stands between the client and the load balanced instances. Is that how you're doing it? How do you plan to keep the data in synch if you load balance between the two? If the connections aren't "sticky", you'll expect to find INSERTed data in both instances.

Maybe this reference can help you get started:

http://www.howtoforge.com/loadbalanced_mysql_cluster_debian

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文