【发布时间】:2012-11-15 03:59:45
【问题描述】:
我的环境有 2 个 MySQL 服务器(INS1 和 INS2),当我测试故障转移模式时,INS1 关闭,驱动程序创建与 INS2 的连接,连接速度非常慢(Glassfish 连接池也发生了这种情况。)
final String connstr = "jdbc:mysql://INS1,INS2:3306/mysql";
Properties props = new Properties();
props.put("user", "xxx");
props.put("password", "xxx");
props.put("failOverReadOnly", "false");
props.put("roundRobinLoadBalance", "false");
return DriverManager.getConnection(connstr, props);
如何调整 jdbc 属性?
run:当 INS1 运行时。信息:在 350 毫秒内连接
INFO:在 16 毫秒内连接
INFO:15 毫秒内连接
INFO:17 毫秒内连接
INFO:15 毫秒内连接
信息:在 16 毫秒内连接成功(总时间:0 秒)
运行:当 INS1 关闭时。信息:在 1,380 毫秒内连接
信息:在 1,060 毫秒内连接
信息:在 1,058 毫秒内连接
信息:在 1,060 毫秒内连接
信息:在 1,055 毫秒内连接
信息:在 1,041 毫秒内连接成功(总时间:6 秒)
【问题讨论】:
标签: java mysql performance jdbc failover