Mycat启动出现的报错字段及解决方法

Mycat报错案例

案例一

  1. Unable to start JVM: No such file or directory出现找不到或开启不了JVM报错时,其实就是程序在$PATH相对路径下找不到java的启动路径
#报错开启不了JVM
[root@localhost bin]# tail -fn 20 /usr/local/mycat/logs/wrapper.log
STATUS | wrapper  | 2022/12/09 11:39:10 | --> Wrapper Started as Daemon
STATUS | wrapper  | 2022/12/09 11:39:10 | Launching a JVM...
ERROR  | wrapper  | 2022/12/09 11:39:10 | Unable to start JVM: No such file or directory (2)
ERROR  | wrapper  | 2022/12/09 11:39:10 | JVM exited while loading the application.
STATUS | wrapper  | 2022/12/09 11:39:15 | Launching a JVM...
ERROR  | wrapper  | 2022/12/09 11:39:15 | Unable to start JVM: No such file or directory (2)
ERROR  | wrapper  | 2022/12/09 11:39:15 | JVM exited while loading the application.
STATUS | wrapper  | 2022/12/09 11:39:19 | Launching a JVM...
ERROR  | wrapper  | 2022/12/09 11:39:19 | Unable to start JVM: No such file or directory (2)
ERROR  | wrapper  | 2022/12/09 11:39:19 | JVM exited while loading the application.
STATUS | wrapper  | 2022/12/09 11:39:23 | Launching a JVM...
ERROR  | wrapper  | 2022/12/09 11:39:23 | Unable to start JVM: No such file or directory (2)
ERROR  | wrapper  | 2022/12/09 11:39:23 | JVM exited while loading the application.
STATUS | wrapper  | 2022/12/09 11:39:27 | Launching a JVM...
ERROR  | wrapper  | 2022/12/09 11:39:27 | Unable to start JVM: No such file or directory (2)
ERROR  | wrapper  | 2022/12/09 11:39:27 | JVM exited while loading the application.
FATAL  | wrapper  | 2022/12/09 11:39:27 | There were 5 failed launches in a row, each lasting less than 300 seconds.  Giving up.
FATAL  | wrapper  | 2022/12/09 11:39:27 |   There may be a configuration problem: please check the logs.
STATUS | wrapper  | 2022/12/09 11:39:27 | <-- Wrapper Stopped

#在$PATH下没有java相对路径
[root@localhost bin]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost bin]#
[root@localhost bin]# /usr/java/jdk1.8.0_131/bin/java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
[root@localhost bin]# 

#把路径添加到PATH
[root@localhost bin]# export PATH=$PATH:/usr/java/jdk1.8.0_131/bin
[root@localhost bin]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.8.0_131/bin
[root@localhost bin]# 

案例二

  1. Caused by: java.net.ConnectException: 拒绝连接 (Connection refused) 因Mycat刚部署完成不知道哪个是Master哪个是Slave所以出现这个报错。
  2. 所以需要修改Mycat的datasource目录下的配置文件,需要指定主库创建并授权的用户、密码、主从库的IP地址、端口、原型数据库、实例类型才能连接到主从库中
[root@localhost bin]# tail -fn 20 /usr/local/mycat/logs/wrapper.log 
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:89)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at com.mysql.cj.NativeSession.connect(NativeSession.java:144)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:847)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	... 7 common frames omitted
INFO   | jvm 1    | 2022/12/09 12:11:09 | Caused by: java.net.ConnectException: 拒绝连接 (Connection refused)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at java.net.PlainSocketImpl.socketConnect(Native Method)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at java.net.Socket.connect(Socket.java:589)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:63)
INFO   | jvm 1    | 2022/12/09 12:11:09 | 	... 9 common frames omitted
STATUS | wrapper  | 2022/12/09 12:11:10 | <-- Wrapper Stopped

案例三

[ERROR]com.alibaba.druid.pool.D
ruidDataSource.run:2803create connection SQLException, url: jdbc:mysql://192.168.100.112/mycat?s
erverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true, errorCod

  1. 以上报错字段因MySQL主库中的root用户授权是localhost导致的 ,把在主库中把root用户的授权由localhost改为 ‘%’ ;mycat才能通过root账号连上MySQL
[root@localhost logs]# more wrapper.log 
STATUS | wrapper  | 2022/12/09 17:09:23 | --> Wrapper Started as Daemon
STATUS | wrapper  | 2022/12/09 17:09:23 | Launching a JVM...
INFO   | jvm 1    | 2022/12/09 17:09:23 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.
org
INFO   | jvm 1    | 2022/12/09 17:09:23 |   Copyright 1999-2006 Tanuki Software, Inc.  All Right
s Reserved.
INFO   | jvm 1    | 2022/12/09 17:09:23 | 
INFO   | jvm 1    | 2022/12/09 17:09:24 | path:/usr/local/mycat/./conf
INFO   | jvm 1    | 2022/12/09 17:09:24 | 2022-12-09 17:09:24,409[INFO]com.alibaba.druid.pool.Dr
uidDataSource.init:990{dataSource-1} inited
INFO   | jvm 1    | 2022/12/09 17:09:27 | 2022-12-09 17:09:27,418[WARN]com.alibaba.druid.pool.Dr
uidDataSource.getConnectionDirect:1424get connection timeout retry : 1
INFO   | jvm 1    | 2022/12/09 17:09:28 | 2022-12-09 17:09:28,612[ERROR]com.alibaba.druid.pool.D
ruidDataSource.run:2803create connection SQLException, url: jdbc:mysql://192.168.100.112/mycat?s
erverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true, errorCod
e 0, state 08001
INFO   | jvm 1    | 2022/12/09 17:09:28 | java.sql.SQLNonTransientConnectionException: Could not
 create connection to database server. Attempted reconnect 3 times. Giving up.
INFO   | jvm 1    | 2022/12/09 17:09:28 | 	at com.mysql.cj.jdbc.exceptions.SQLError.createS
QLException(SQLError.java:110)
mysql> update mysql.user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> 

mysql> select user,host from mysql.user where user='root'\G
*************************** 1. row ***************************
user: root
host: %
1 row in set (0.12 sec)

mysql> 

案例四

cn.mycat.vertx.xa.impl.Xa
LogImpl.?:?java.sql.SQLException: XAER_RMERR: Fatal error occurred in the transaction branch - check your data for consistency

  1. 以上报错表示连接数据库的用户没有xa_recover_admin权限
  2. 在数据库中对该用户重新授权即可
[root@localhost logs]# more wrapper.log 
STATUS | wrapper  | 2022/12/09 17:27:41 | --> Wrapper Started as Daemon
STATUS | wrapper  | 2022/12/09 17:27:42 | Launching a JVM...
INFO   | jvm 1    | 2022/12/09 17:27:42 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.
org
INFO   | jvm 1    | 2022/12/09 17:27:42 |   Copyright 1999-2006 Tanuki Software, Inc.  All Right
s Reserved.
INFO   | jvm 1    | 2022/12/09 17:27:42 | 
INFO   | jvm 1    | 2022/12/09 17:27:42 | path:/usr/local/mycat/./conf
INFO   | jvm 1    | 2022/12/09 17:27:43 | 2022-12-09 17:27:43,093[INFO]com.alibaba.druid.pool.Dr
uidDataSource.init:990{dataSource-1} inited
INFO   | jvm 1    | 2022/12/09 17:27:43 | 2022-12-09 17:27:43,350[INFO]com.alibaba.druid.pool.Dr
uidDataSource.init:990{dataSource-2} inited
INFO   | jvm 1    | 2022/12/09 17:27:44 | 2022-12-09 17:27:44,116[INFO]io.mycat.config.MycatRout
erConfigOps.recoveryXA:735readXARecoveryLog start
INFO   | jvm 1    | 2022/12/09 17:27:44 | 2022-12-09 17:27:44,223[WARN]cn.mycat.vertx.xa.impl.Xa
LogImpl.?:?java.sql.SQLException: XAER_RMERR: Fatal error occurred in the transaction branch - c
heck your data for consistency
INFO   | jvm 1    | 2022/12/09 17:27:44 | 2022-12-09 17:27:44,225[WARN]cn.mycat.vertx.xa.impl.Xa
LogImpl.?:?java.sql.SQLException: XAER_RMERR: Fatal error occurred in the transaction branch - c
heck your data for consistency
INFO   | jvm 1    | 2022/12/09 17:27:44 | 2022-12-09 17:27:44,250[INFO]io.mycat.vertx.VertxMycat
Server.lambda$start$1:166Mycat Vertx server 2b4f2ad8-9919-4acf-b2ec-95accaf340e9 started up.
INFO   | jvm 1    | 2022/12/09 17:27:44 | 2022-12-09 17:27:44,250[INFO]io.mycat.vertx.VertxMycat
Server.lambda$start$1:166Mycat Vertx server 11588fd2-fd63-4719-8c3f-392c99aea303 started up.

案例五

  1. 当在主库创建数据库、表和插入数据后,从库可以同步,但在客户端无法查看表内数据库;可正常查看表格式
  2. 出现这种情况可以通过重启mycat服务解决
mysql> select * from t1;
ERROR: 
org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: Object 't1' not found within 'discuz'
mysql> 

mysql> use discuz;
Database changed
mysql> desc t1;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int         | YES  |     | NULL    |       |
| name  | varchar(20) | YES  |     | NULL    |       |
| job   | char(20)    | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.03 sec)

mysql>


[root@localhost logs]# /usr/local/mycat/bin/mycat restart 
Stopping mycat2...
Stopped mycat2.
Starting mycat2...
[root@localhost logs]#
[root@sunlit5 ~]# mysql -h 192.168.100.111 -uroot -pAdmin@123 -P 8066
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 0
Server version: 5.7.33-mycat-2.0 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| `Database`         |
+--------------------+
| discuz             |
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.05 sec)

mysql> use discuz;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from t1;
+------+----------+------+
| id   | name     | job  |
+------+----------+------+
|    1 | xiaoming | IT   |
|    2 | xiaowang | IT   |
+------+----------+------+
2 rows in set (0.02 sec)

mysql> 

案例六

[ERROR]com.alibaba.druid.pool.DruidDataSource.run:2803create connection SQLException, url: jdbc:mysql://192.168.100.112:3306/myca
t?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true, errorCode 0, state 08001

  1. 当mycat启动时出现该报错,表示MySQL中的时区与mycat的时区不一致,需要在MySQL中设置时区
  2. 时区设置完后,重启mycat即可
[root@localhost logs]# more wrapper.log 
STATUS | wrapper  | 2022/12/10 23:52:06 | --> Wrapper Started as Daemon
STATUS | wrapper  | 2022/12/10 23:52:06 | Launching a JVM...
INFO   | jvm 1    | 2022/12/10 23:52:07 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
INFO   | jvm 1    | 2022/12/10 23:52:07 |   Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.
INFO   | jvm 1    | 2022/12/10 23:52:07 | 
INFO   | jvm 1    | 2022/12/10 23:52:07 | path:/usr/local/mycat/./conf
INFO   | jvm 1    | 2022/12/10 23:52:07 | 2022-12-10 23:52:07,788[INFO]com.alibaba.druid.pool.DruidDataSource.init:990{dataSource-1} inited
INFO   | jvm 1    | 2022/12/10 23:52:10 | 2022-12-10 23:52:10,790[WARN]com.alibaba.druid.pool.DruidDataSource.getConnectionDirect:1424get connection timeout retry : 1
INFO   | jvm 1    | 2022/12/10 23:52:12 | 2022-12-10 23:52:12,010[ERROR]com.alibaba.druid.pool.DruidDataSource.run:2803create connection SQLException, url: jdbc:mysql://192.168.100.112:3306/myca
t?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true, errorCode 0, state 08001
INFO   | jvm 1    | 2022/12/10 23:52:12 | java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
INFO   | jvm 1    | 2022/12/10 23:52:12 | 	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
INFO   | jvm 1    | 2022/12/10 23:52:12 | 	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
INFO   | jvm 1    | 2022/12/10 23:52:12 | 	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
INFO   | jvm 1    | 2022/12/10 23:52:12 | 	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
INFO   | jvm 1    | 2022/12/10 23:52:12 | 	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
INFO   | jvm 1    | 2022/12/10 23:52:12 | 	at com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:903)
INFO   | jvm 1    | 2022/12/10 23:52:12 | 	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:828)
INFO   | jvm 1    | 2022/12/10 23:52:12 | 	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:453)
INFO   | jvm 1    | 2022/12/10 23:52:12 | 	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
INFO   | jvm 1    | 2022/12/10 23:52:12 | 	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
mysql> set global time_zone='+8:00';
Query OK, 0 rows affected (0.00 sec)

mysql> set time_zone='+8:00';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> select curtime();
+-----------+
| curtime() |
+-----------+
| 10:42:51  |
+-----------+
1 row in set (0.00 sec)

mysql> 
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值