博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mycat mysql毫秒,mycat 配置mysql读写分离+高可用切换不过去
阅读量:6158 次
发布时间:2019-06-21

本文共 6272 字,大约阅读时间需要 20 分钟。

配置文件:

select user()

错误日志:

2020-10-22 17:42:05.090 ERROR [Timer0] (io.mycat.backend.jdbc.JDBCHeartbeat.heartbeat(JDBCHeartbeat.java:114)) - JDBCHeartBeat error

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:456) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at java.sql.DriverManager.getConnection(DriverManager.java:664) ~[?:1.8.0_251]

at java.sql.DriverManager.getConnection(DriverManager.java:247) ~[?:1.8.0_251]

at io.mycat.backend.jdbc.JDBCDatasource.getConnection(JDBCDatasource.java:109) ~[Mycat-server-1.6.5-release.jar:?]

at io.mycat.backend.jdbc.JDBCHeartbeat.heartbeat(JDBCHeartbeat.java:100) ~[Mycat-server-1.6.5-release.jar:?]

at io.mycat.backend.datasource.PhysicalDatasource.doHeartbeat(PhysicalDatasource.java:440) ~[Mycat-server-1.6.5-release.jar:?]

at io.mycat.backend.datasource.PhysicalDBPool.doHeartbeat(PhysicalDBPool.java:345) ~[Mycat-server-1.6.5-release.jar:?]

at io.mycat.MycatServer$8$1.run(MycatServer.java:897) ~[Mycat-server-1.6.5-release.jar:?]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_251]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_251]

at java.lang.Thread.run(Thread.java:748) [?:1.8.0_251]

Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

at sun.reflect.GeneratedConstructorAccessor18.newInstance(Unknown Source) ~[?:?]

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_251]

at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_251]

at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:91) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.NativeSession.connect(NativeSession.java:144) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:956) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826) ~[mysql-connector-java-8.0.19.jar:8.0.19]

... 13 more

Caused by: java.net.ConnectException: 拒绝连接 (Connection refused)

at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:1.8.0_251]

at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:1.8.0_251]

at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:1.8.0_251]

at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:1.8.0_251]

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:1.8.0_251]

at java.net.Socket.connect(Socket.java:606) ~[?:1.8.0_251]

at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.NativeSession.connect(NativeSession.java:144) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:956) ~[mysql-connector-java-8.0.19.jar:8.0.19]

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826) ~[mysql-connector-java-8.0.19.jar:8.0.19]

问题描述:

正常四台server_id=1 ;2; 3; 4

1;2为双主 3;4为从

mysql> select @@server_id;

+-------------+

| @@server_id |

+-------------+

| 4 |

+-------------+

1 row in set (0.01 sec)

mysql> select @@server_id;

+-------------+

| @@server_id |

+-------------+

| 3 |

+-------------+

1 row in set (0.00 sec)

mysql> select @@server_id;

+-------------+

| @@server_id |

+-------------+

| 1 |

+-------------+

1 row in set (0.01 sec)

mysql> begin ;select @@server_id; commit;

Query OK, 0 rows affected (0.00 sec)

+-------------+

| @@server_id |

+-------------+

| 2 |

+-------------+

1 row in set (0.01 sec)

关掉server_id=2 的那台,会出现读的还是在server_id=1上,他没有切换成写的数据库

+-------------+

| @@server_id |

+-------------+

| 1 |

+-------------+

1 row in set (0.01 sec)

mysql> select @@server_id;

+-------------+

| @@server_id |

+-------------+

| 3 |

+-------------+

1 row in set (0.00 sec)

mysql> select @@server_id;

+-------------+

| @@server_id |

+-------------+

| 1 |

+-------------+

1 row in set (0.01 sec)

mysql> select @@server_id;

+-------------+

| @@server_id |

+-------------+

| 3 |

+-------------+

1 row in set (0.01 sec)

mysql> begin ;select @@server_id; commit;

Query OK, 0 rows affected (0.00 sec)

ERROR:

No operations allowed after connection closed.

ERROR 1003 (HY000): Transaction error, need to rollback.

mysql> begin ;select @@server_id; commit;

Query OK, 0 rows affected (0.00 sec)

ERROR 1003 (HY000): Transaction error, need to rollback. errno:0 No operations allowed after connection closed.

ERROR 1003 (HY000): Transaction error, need to rollback.

转载地址:http://ykifa.baihongyu.com/

你可能感兴趣的文章
Windows phone 8 学习笔记(3) 通信
查看>>
Revit API找到风管穿过的墙(当前文档和链接文档)
查看>>
Scroll Depth – 衡量页面滚动的 Google 分析插件
查看>>
Windows 8.1 应用再出发 - 视图状态的更新
查看>>
自己制作交叉编译工具链
查看>>
Qt Style Sheet实践(四):行文本编辑框QLineEdit及自动补全
查看>>
[物理学与PDEs]第3章习题1 只有一个非零分量的磁场
查看>>
深入浅出NodeJS——数据通信,NET模块运行机制
查看>>
onInterceptTouchEvent和onTouchEvent调用时序
查看>>
android防止内存溢出浅析
查看>>
4.3.3版本之引擎bug
查看>>
SQL Server表分区详解
查看>>
使用FMDB最新v2.3版本教程
查看>>
STM32启动过程--启动文件--分析
查看>>
垂死挣扎还是涅槃重生 -- Delphi XE5 公布会归来感想
查看>>
淘宝的几个架构图
查看>>
linux后台运行程序
查看>>
Python异步IO --- 轻松管理10k+并发连接
查看>>
Oracle中drop user和drop user cascade的区别
查看>>
登记申请汇总
查看>>