1. 程式人生 > >mycat啟動報錯 Caused by: org.opencloudb.config.util.ConfigException: dataNode node_db01 reference dataHo

mycat啟動報錯 Caused by: org.opencloudb.config.util.ConfigException: dataNode node_db01 reference dataHo

環境:mycat 1.5

作業系統:Redhat 6.5 64位

JDK:1.8.0_181

mysql:5.6.35

現象描述:當啟動mycat時,提示: Caused by: org.opencloudb.config.util.ConfigException: dataNode node_db01 reference dataHost:mycat not exists!

1、啟動mycat時報錯資訊如下:

[[email protected] 3306]# /usr/local/mycat/bin/mycat console start
Running Mycat-server...
wrapper  | --> Wrapper Started as Console
wrapper  | Launching a JVM...
jvm 1    | Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=64M; support was removed in 8.0
jvm 1    | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1    |   Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.
jvm 1    |
jvm 1    |
jvm 1    | WrapperSimpleApp: Encountered an error running main: java.lang.ExceptionInInitializerError
jvm 1    | java.lang.ExceptionInInitializerError
jvm 1    |     at org.opencloudb.MycatStartup.main(MycatStartup.java:50)
jvm 1    |     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
jvm 1    |     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
jvm 1    |     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
jvm 1    |     at java.lang.reflect.Method.invoke(Method.java:498)
jvm 1    |     at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
jvm 1    |     at java.lang.Thread.run(Thread.java:748)
jvm 1    | Caused by: org.opencloudb.config.util.ConfigException: dataNode node_db01 reference dataHost:mycat not exists!


jvm 1    |     at org.opencloudb.config.loader.xml.XMLSchemaLoader.createDataNode(XMLSchemaLoader.java:545)
jvm 1    |     at org.opencloudb.config.loader.xml.XMLSchemaLoader.loadDataNodes(XMLSchemaLoader.java:516)
jvm 1    |     at org.opencloudb.config.loader.xml.XMLSchemaLoader.load(XMLSchemaLoader.java:106)
jvm 1    |     at org.opencloudb.config.loader.xml.XMLSchemaLoader.<init>(XMLSchemaLoader.java:71)
jvm 1    |     at org.opencloudb.config.loader.xml.XMLSchemaLoader.<init>(XMLSchemaLoader.java:75)
jvm 1    |     at org.opencloudb.ConfigInitializer.<init>(ConfigInitializer.java:63)
jvm 1    |     at org.opencloudb.MycatConfig.<init>(MycatConfig.java:69)
jvm 1    |     at org.opencloudb.MycatServer.<init>(MycatServer.java:105)
jvm 1    |     at org.opencloudb.MycatServer.<clinit>(MycatServer.java:73)
jvm 1    |     ... 7 more
wrapper  | <-- Wrapper Stopped

2、解決方法:

修改schema.xml

<dataHost name="mycat" maxCon="1000" minCon="10" balance="0"
        writeType="0" dbType="mysql" dbDriver="native" switchType="1"  slaveThreshold="100">
        <heartbeat>select user()</heartbeat>
        <!-- can have multi write hosts -->
        <writeHost host="mycat" url="192.168.4.116:3306" user="root"
            password="123456">
            <!-- can have multi read hosts -->
            <!--<readHost host="hostS2" url="192.168.1.200

:3306" user="root" password="xxx" />-->
        </writeHost>
        <!--<writeHost host="hostS1" url="localhost:3316" user="root"-->
            <!--password="123456" />-->
        <!-- <writeHost host="hostM2" url="localhost:3316" user="root" password="123456"/> -->
    </dataHost>

3、再次啟動mycat,顯示啟動成功
[[email protected] 3306]# /usr/local/mycat/bin/mycat console start
Running Mycat-server...
wrapper  | --> Wrapper Started as Console
wrapper  | Launching a JVM...
jvm 1    | Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=64M; support was removed in 8.0
jvm 1    | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1    |   Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.
jvm 1    |
jvm 1    | log4j 2018-09-10 16:25:35 [./conf/log4j.xml] load completed.
jvm 1    | MyCAT Server startup successfully. see logs in logs/mycat.log

4、查詢mycat程序是否存在

[[email protected] mysql]# ps -ef|grep mycat
mysql      7158   6058  0 16:00 pts/0    00:00:02 /usr/local/mysql/bin/mysqld --defaults-file=/etc/3306.cnf --basedir=/usr/local/mysql --datadir=/mysql/data/3306/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/mysql/data/3306/data/mycat.err --open-files-limit=8192 --pid-file=/mysql/data/3306/data/mysqld.pid --socket=/mysql/data/3306/data/mysql.sock --port=3306
root       7771   2241  0 16:31 pts/0    00:00:00 /bin/sh /usr/local/mycat/bin/mycat console start
root       7818   7771  0 16:31 pts/0    00:00:00 /usr/local/mycat/bin/./wrapper-linux-x86-64 /usr/local/mycat/conf/wrapper.conf wrapper.syslog.ident=mycat wrapper.pidfile=/usr/local/mycat/logs/mycat.pid wrapper.lockfile=/var/lock/subsys/mycat
root       7857   2241  0 16:31 pts/0    00:00:00 grep mycat