编辑了下SCHEMA.XML
<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">;
<schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
<dataNode name="dn1" dataHost="zabbix" database="mycat" />
<dataHost name="zabbix" maxCon="1000" minCon="10" balance="0"
writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<writeHost host="zabbix8" url="10.0.8.6:3306" user="root" password="123456">
<readHost host="hostS2" url="10.0.7.5:3306" user="root" password="123456" />
</writeHost>
<writeHost host="hostS1" url="10.0.7.5:3316" user="root" password="123456" />
</dataHost>
</mycat:schema>
找了两个MYSQL实例分别是7.5和8.6。逻辑库系统默认的TESTDB
注解了其他逻辑节点,保留1个逻辑节点DN1。
并把逻辑库TESTDB默认关联到DN1。
物理节点组命名为ZABBIX DATABASE=MYCAT。
物理节点组,主库为zabbix8 url 10.0.8.6
从库1 hostS2 10.0.7.5
备用主库 hostS1 10.0.7.5
然后用navicat 分别连接到两个实例,手动创建数据库mycat.
server.xml配置 原封不动
<user name="root" defaultAccount="true">
<property name="password">123456</property>
<property name="schemas">TESTDB</property>
</user>
<user name="user">
<property name="password">user</property>
<property name="schemas">TESTDB</property>
<property name="readOnly">true</property>
</user>
默认定义了两个用户ROOT和USER。
第一次撩
[root@DBA_ZABBIX bin]# ./mycat start
Starting Mycat-server...
用SQLYLOG工具连接不成功,小姐姐京瓷了,不让上!
10.0.8.6:8066 root/123456
然后去看日志
[root@DBA_ZABBIX logs]# ll
total 7656
drwxr-xr-x 2 root root 4096 Jun 25 00:00 2019-06
-rw-r--r-- 1 root root 7785434 Jun 24 15:15 bak_01_mycat.log
-rw-r--r-- 1 root root 0 Jun 25 16:38 mycat.log
-rw-r--r-- 1 root root 37227 Jun 25 08:58 switch.log
-rw-r--r-- 1 root root 7202 Jun 25 16:38 wrapper.log
日志为空!
用CONSOLE排查启动错误
[root@DBA_ZABBIX bin]# ./mycat st
Usage: ./mycat { console | start | stop | restart | status | dump }
很烦JAVA日志,搞一大堆无用的字符
比如:at com.sun.org.apache.xerces.internal.
[root@DBA_ZABBIX bin]# ./mycat console
Running Mycat-server...
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
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 io.mycat.MycatStartup.main(MycatStartup.java:53)
jvm 1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
jvm 1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
jvm 1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
jvm 1 | at java.lang.reflect.Method.invoke(Method.java:606)
jvm 1 | at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
jvm 1 | at java.lang.Thread.run(Thread.java:745)
jvm 1 | Caused by: io.mycat.config.util.ConfigException: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 7; The string "--" is not permitted within comments.
jvm 1 | at io.mycat.config.loader.xml.XMLSchemaLoader.load(XMLSchemaLoader.java:121)
jvm 1 | at io.mycat.config.loader.xml.XMLSchemaLoader.<init>(XMLSchemaLoader.java:78)
jvm 1 | at io.mycat.config.loader.xml.XMLSchemaLoader.<init>(XMLSchemaLoader.java:82)
jvm 1 | at io.mycat.config.ConfigInitializer.<init>(ConfigInitializer.java:76)
jvm 1 | at io.mycat.config.MycatConfig.<init>(MycatConfig.java:72)
jvm 1 | at io.mycat.MycatServer.<init>(MycatServer.java:158)
jvm 1 | at io.mycat.MycatServer.<clinit>(MycatServer.java:101)
jvm 1 | ... 7 more
jvm 1 | Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 7; The string "--" is not permitted within comments.
jvm 1 | at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
jvm 1 | at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
jvm 1 | at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
jvm 1 | at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
jvm 1 | at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1465)
jvm 1 | at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanComment(XMLScanner.java:820)
jvm 1 | at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanComment(XMLDocumentFragmentScannerImpl.java:1033)
jvm 1 | at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2979)
jvm 1 | at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
jvm 1 | at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:504)
jvm 1 | at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
jvm 1 | at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
jvm 1 | at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
jvm 1 | at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)
jvm 1 | at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:338)
jvm 1 | at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)
jvm 1 | at io.mycat.config.util.ConfigUtil.getDocument(ConfigUtil.java:115)
jvm 1 | at io.mycat.config.loader.xml.XMLSchemaLoader.load(XMLSchemaLoader.java:111)
jvm 1 | ... 13 more
wrapper | <-- Wrapper Stopped
[root@DBA_ZABBIX bin]#
看样子是 SCHMAE.XML 配置有问题,
因为在LINUX 使用VIM 颜色不太好
把其他清理后直接贴配置好的进去。
[root@DBA_ZABBIX bin]# ./mycat console
Running Mycat-server...
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
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:WARN No appenders could be found for logger (io.mycat.memory.MyCatMemory).
jvm 1 | log4j:WARN Please initialize the log4j system properly.
jvm 1 | log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
jvm 1 | MyCAT Server startup successfully. see logs in logs/mycat.log
小姐姐终于肯了!
[root@DBA_ZABBIX logs]# ll
total 7700
drwxr-xr-x 2 root root 4096 Jun 25 00:00 2019-06
-rw-r--r-- 1 root root 7785434 Jun 24 15:15 bak_01_mycat.log
-rw-r--r-- 1 root root 26728 Jun 25 16:56 mycat.log
-rw-r--r-- 1 root root 6 Jun 25 16:55 mycat.pid
-rw-r--r-- 1 root root 37319 Jun 25 16:55 switch.log
-rw-r--r-- 1 root root 18565 Jun 25 16:55 wrapper.log
日志也有了
也肯让我上了!
不过空空如也
创建个表试试看
还是有点脾气啊!
<schema name="TESTDB" checkSQLschema="true" sqlMaxLimit="100" dataNode="dn1">
checkSQLschema改成TURE
CTRL+C 中断./mycat console mycat 同时也下线。使用start命令让小姐姐再上去
[root@DBA_ZABBIX bin]# ./mycat start
Starting Mycat-server...
表创建成功了!
从另外个工具上看表只在ZABBIX物理上创建了表,7.5没有表!
因为MYCAT不支持多写,也没有搭建主从。那我们人工去创建它就行了。