Open java-han opened 2 years ago
在1.20里版本里,这个错误是某个集群中的数据源配置有问题,找不到数据源导致的
可以使用1.21,可能没有这个问题
配置只配置了一个集群,一个主节点,一个子节点,主节点 只写,子节点 只读,数据库都是mysql,也配置了主从复制,启动后虽然报错,但是可以查询,可以修改。都没有什么问题, 刚换成1.21版本 配置文件没动 启动没有报错信息了
刚刚发现另一个问题,通过mycat创建的表,主数据库里面存在,从数据库里面没有,检查从数据库复制功能状态,没有错误都是正常的,然后从主数据库创建表,从库里面会存在,通过mycat也能看到表,但是查询会报表不存在,是需要在创建表SQL前添加注解吗?就像https://github.com/MyCATApache/Mycat2/issues/170 这样??
以下是我的配置文件: prototype.cluster.json: { "clusterType":"MASTER_SLAVE", "heartbeat":{ "heartbeatTimeout":1000, "maxRetryCount":3, "minSwitchTimeInterval":300, "slaveThreshold":0 }, "masters":[ "221-3306" ], "replicas":[ "241-3306" ], "maxCon":200, "name":"prototype", "readBalanceType":"BALANCE_READ_WRITE", "switchType":"NOT_SWITCH", "timer":{ "initialDelay":1, "period":5, "timeUnit":"SECONDS" }, "readBalanceName":"BalanceLeastActive", "writeBalanceName":"BalanceLeastActive" }
221-3306.datasource.json: { "dbType":"mysql", "idleTimeout":60000, "initSqls":[], "initSqlsGetConnection":true, "instanceType":"WRITE", "maxCon":1000, "maxConnectTimeout":3000, "maxRetryCount":5, "minCon":1, "name":"221-3306", "password":"****", "type":"JDBC", "url":"jdbc:mysql://xxx:3306/mysql?useSSL=false&useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=UTF-8", "user":"root", "weight":0, }
241-3306.datasource.json: { "dbType":"mysql", "idleTimeout":60000, "initSqls":[], "initSqlsGetConnection":true, "instanceType":"READ", "maxCon":1000, "maxConnectTimeout":3000, "maxRetryCount":5, "minCon":1, "name":"241-3306", "password":"****", "type":"JDBC", "url":"jdbc:mysql://xxx:3306/mysql?useSSL=false&useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=UTF-8", "user":"root", "weight":0, }
schemas是通过SQL create database ***; 自动创建的
刚刚发现另一个问题,通过mycat创建的表,主数据库里面存在,从数据库里面没有,检查从数据库复制功能状态,没有错误都是正常的,然后从主数据库创建表,从库里面会存在,通过mycat也能看到表,但是查询会报表不存在,是需要在创建表SQL前添加注解吗?就像#170 这样??
这个问题是几个问题混在一起的.
1.21中,mycat看到的表,肯定在mycat里面是有配置的.表不存在的异常肯定是mysql上不存在.通过注释创建表不会在mysql上创建表.
INFO | jvm 1 | 2022/01/14 14:37:00 | 2022-01-14 14:37:00,820[ERROR]io.mycat.config.ConfigPrepareExecuter.lambda$fullInitBy$6:187 INFO | jvm 1 | 2022/01/14 14:37:00 | java.lang.NullPointerException: null INFO | jvm 1 | 2022/01/14 14:37:00 | at java.util.Objects.requireNonNull(Objects.java:203) INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.MetaClusterCurrent.wrapper(MetaClusterCurrent.java:14) INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.config.ConfigPrepareExecuter.lambda$fullInitBy$6(ConfigPrepareExecuter.java:184) INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.replica.ReplicaSelectorRuntime.lambda$registerDatasource$7(ReplicaSelectorRuntime.java:262) INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.replica.PhysicsInstanceImpl.getSessionCounter(PhysicsInstanceImpl.java:112) INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.plug.loadBalance.BalanceLeastActive$1.select(BalanceLeastActive.java:42) INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.replica.ReplicaSelectorRuntime.getDatasource(ReplicaSelectorRuntime.java:366) INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.replica.ReplicaSelectorRuntime.getWriteDatasource(ReplicaSelectorRuntime.java:346) INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.replica.ReplicaSelectorRuntime.getDatasourceNameByReplicaName(ReplicaSelectorRuntime.java:152) INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.monitor.MonitorReplicaSelectorManager.getDatasourceNameByReplicaName(MonitorReplicaSelectorManager.java:26) INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.replica.ReplicaSelectorManager.getDatasourceNameByReplicaName(ReplicaSelectorManager.java:30) INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.datasource.jdbc.datasource.JdbcConnectionManager.lambda$getConnection$2(JdbcConnectionManager.java:123) INFO | jvm 1 | 2022/01/14 14:37:00 | at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.datasource.jdbc.datasource.JdbcConnectionManager.getConnection(JdbcConnectionManager.java:122) INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.datasource.jdbc.datasource.JdbcConnectionManager.getConnection(JdbcConnectionManager.java:117) INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.MetadataManager.(MetadataManager.java:165)
INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.MetadataManager.createMetadataManager(MetadataManager.java:124)
INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.config.ConfigPrepareExecuter.fullInitBy(ConfigPrepareExecuter.java:217)
INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.config.ConfigPrepareExecuter.prepareRuntimeObject(ConfigPrepareExecuter.java:135)
INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.config.FileMetadataStorageManager.commitAndSyncDisk(FileMetadataStorageManager.java:271)
INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.config.FileMetadataStorageManager$1.commit(FileMetadataStorageManager.java:250)
INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.config.FileMetadataStorageManager.start(FileMetadataStorageManager.java:209)
INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.config.FileMetadataStorageManager.start(FileMetadataStorageManager.java:204)
INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.MycatCore.startServer(MycatCore.java:216)
INFO | jvm 1 | 2022/01/14 14:37:00 | at io.mycat.MycatCore.main(MycatCore.java:235)
INFO | jvm 1 | 2022/01/14 14:37:00 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO | jvm 1 | 2022/01/14 14:37:00 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
INFO | jvm 1 | 2022/01/14 14:37:00 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
INFO | jvm 1 | 2022/01/14 14:37:00 | at java.lang.reflect.Method.invoke(Method.java:498)
INFO | jvm 1 | 2022/01/14 14:37:00 | at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
INFO | jvm 1 | 2022/01/14 14:37:00 | at java.lang.Thread.run(Thread.java:748)
INFO | jvm 1 | 2022/01/14 14:37:00 | 2022-01-14 14:37:00,822[ERROR]io.mycat.config.ConfigPrepareExecuter.lambda$fullInitBy$6:187