mycat 新增分片和字符集
执行 select * from travelrecord ,分析Debug日志,说明整个执行逻辑,包括连接获取,连接同步信息,数据合并,数据返回,连接释放
新增一个分片表 T_VOTE (ID,PROVINCE),PROVINCE用hash分片 ,并用reload命令方式重载生效, 截图和文字说明整个过程。
MySQL Server里Server端字符集UTF8情况下,当客户端字符集配置为latin 与UTF8的情况下,,通过MySQL客户端登录Mycat,执行select操作,通过日志分析,看看MyCAT的执行过程有哪些差别。
1:
mysql> select * from travelrecord;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 6
Current database: TESTDB
+---------+---------+------------+------+------+
| id | user_id | traveldate | fee | days |
+---------+---------+------------+------+------+
| 1 | wang | 2014-01-05 | 511 | 3 |
| 7000001 | wang | 2014-01-05 | 511 | 3 |
+---------+---------+------------+------+------+
2 rows in set (0.26 sec)
[mysql@hongquan ~]$ mysql -usystem -pmysql -P9066 -h10.0.1.134 -DTESTDB
mysql> show @@cache;
+-------------------------------------+-------+------+--------+------+------+---------------+---------------+
| CACHE | MAX | CUR | ACCESS | HIT | PUT | LAST_ACCESS | LAST_PUT |
+-------------------------------------+-------+------+--------+------+------+---------------+---------------+
| ER_SQL2PARENTID | 1000 | 0 | 0 | 0 | 0 | 0 | 0 |
| SQLRouteCache | 10000 | 1 | 7 | 0 | 2 | 1478596909351 | 1478596909353 |
| TableID2DataNodeCache.TESTDB_ORDERS | 50000 | 0 | 0 | 0 | 0 | 0 | 0 |
+-------------------------------------+-------+------+--------+------+------+---------------+---------------+
执行查询
mysql> select * from company;
mysql> select * from travelrecord;
mysql> show @@cache;
+-------------------------------------+-------+------+--------+------+------+---------------+---------------+
| CACHE | MAX | CUR | ACCESS | HIT | PUT | LAST_ACCESS | LAST_PUT |
+-------------------------------------+-------+------+--------+------+------+---------------+---------------+
| ER_SQL2PARENTID | 1000 | 0 | 0 | 0 | 0 | 0 | 0 |
| SQLRouteCache | 10000 | 1 | 12 | 3 | 2 | 1478596994245 | 1478596909353 |
| TableID2DataNodeCache.TESTDB_ORDERS | 50000 | 0 | 0 | 0 | 0 | 0 | 0 |
debug 日志
2016-11-08 00:33:29.115 INFO [$_NIOREACTOR-0-RW] (io.mycat.net.handler.FrontendAuthenticator.success(FrontendAuthenticator.java:194)) - ServerConnection [id=6, schema=TESTDB, host=10.0.1.134, user=system,txIsolation=3, autocommit=true, schema=TESTDB]'system' login success
2016-11-08 00:33:29.121 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.net.FrontendConnection.query(FrontendConnection.java:288)) - ServerConnection [id=6, schema=TESTDB, host=10.0.1.134, user=system,txIsolation=3, autocommit=true, schema=TESTDB] show databases
2016-11-08 00:33:29.122 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.server.ServerQueryHandler.query(ServerQueryHandler.java:57)) - ServerConnection [id=6, schema=TESTDB, host=10.0.1.134, user=system,txIsolation=3, autocommit=true, schema=TESTDB]show databases
2016-11-08 00:33:29.127 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.net.FrontendConnection.query(FrontendConnection.java:288)) - ServerConnection [id=6, schema=TESTDB, host=10.0.1.134, user=system,txIsolation=3, autocommit=true, schema=TESTDB] show tables
2016-11-08 00:33:29.127 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.server.ServerQueryHandler.query(ServerQueryHandler.java:57)) - ServerConnection [id=6, schema=TESTDB, host=10.0.1.134, user=system,txIsolation=3, autocommit=true, schema=TESTDB]show tables
2016-11-08 00:33:29.130 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.net.FrontendConnection.query(FrontendConnection.java:288)) - ServerConnection [id=6, schema=TESTDB, host=10.0.1.134, user=system,txIsolation=3, autocommit=true, schema=TESTDB] select * from travelrecord
2016-11-08 00:33:29.130 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.server.ServerQueryHandler.query(ServerQueryHandler.java:57)) - ServerConnection [id=6, schema=TESTDB, host=10.0.1.134, user=system,txIsolation=3, autocommit=true, schema=TESTDB]select * from travelrecord
2016-11-08 00:33:29.130 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.cache.impl.EnchachePool.get(EnchachePool.java:77)) - SQLRouteCache miss cache ,key:TESTDBselect * from travelrecord
2016-11-08 00:33:29.188 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.cache.impl.EnchachePool.putIfAbsent(EnchachePool.java:60)) - SQLRouteCache add cache ,key:TESTDBselect * from travelrecord value:select * from travelrecord, route={
1 -> dn1{SELECT *
FROM travelrecord
LIMIT 100}
2 -> dn2{SELECT *
FROM travelrecord
LIMIT 100}
3 -> dn3{SELECT *
FROM travelrecord
LIMIT 100}
}
2016-11-08 00:33:29.189 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.server.NonBlockingSession.execute(NonBlockingSession.java:119)) - ServerConnection [id=6, schema=TESTDB, host=10.0.1.134, user=system,txIsolation=3, autocommit=true, schema=TESTDB]select * from travelrecord, route={
1 -> dn1{SELECT *
FROM travelrecord
LIMIT 100}
2 -> dn2{SELECT *
FROM travelrecord
LIMIT 100}
3 -> dn3{SELECT *
FROM travelrecord
LIMIT 100}
} rrs
2016-11-08 00:33:29.235 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.<init>(MultiNodeQueryHandler.java:101)) - execute mutinode query select * from travelrecord
2016-11-08 00:33:29.242 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.<init>(MultiNodeQueryHandler.java:137)) - has data merge logic
2016-11-08 00:33:29.242 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.execute(MultiNodeQueryHandler.java:170)) - rrs.getRunOnSlave()-null
2016-11-08 00:33:29.242 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.execute(MultiNodeQueryHandler.java:185)) - node.getRunOnSlave()1-null
2016-11-08 00:33:29.242 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.execute(MultiNodeQueryHandler.java:187)) - node.getRunOnSlave()2-null
2016-11-08 00:33:29.243 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.datasource.PhysicalDBNode.getConnection(PhysicalDBNode.java:96)) - rrs.getRunOnSlave() null
2016-11-08 00:33:29.243 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.datasource.PhysicalDBNode.getConnection(PhysicalDBNode.java:127)) - rrs.getRunOnSlave() null
2016-11-08 00:33:29.243 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.datasource.PhysicalDBPool.getRWBanlanceCon(PhysicalDBPool.java:456)) - select read source hostS1 for dataHost:localhost0
2016-11-08 00:33:29.244 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.MySQLConnection.synAndDoExecute(MySQLConnection.java:448)) - con need syn ,total syn cmd 1 commands schema change:true con:MySQLConnection [id=117, lastTime=1478594009244, user=system, schema=db1, old shema=db3, borrowed=true, fromSlaveDB=true, threadId=267, charset=utf8, txIsolation=3, autocommit=true, attachment=dn1{SELECT *
FROM travelrecord
LIMIT 100}, respHandler=io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler@64d72a05, host=192.168.3.110, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
2016-11-08 00:33:29.245 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.execute(MultiNodeQueryHandler.java:185)) - node.getRunOnSlave()1-null
2016-11-08 00:33:29.245 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.execute(MultiNodeQueryHandler.java:187)) - node.getRunOnSlave()2-null
2016-11-08 00:33:29.246 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.datasource.PhysicalDBNode.getConnection(PhysicalDBNode.java:96)) - rrs.getRunOnSlave() null
2016-11-08 00:33:29.246 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.datasource.PhysicalDBNode.getConnection(PhysicalDBNode.java:127)) - rrs.getRunOnSlave() null
2016-11-08 00:33:29.246 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.datasource.PhysicalDBPool.getRWBanlanceCon(PhysicalDBPool.java:456)) - select read source hostS1 for dataHost:localhost0
2016-11-08 00:33:29.247 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.execute(MultiNodeQueryHandler.java:185)) - node.getRunOnSlave()1-null
2016-11-08 00:33:29.247 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.execute(MultiNodeQueryHandler.java:187)) - node.getRunOnSlave()2-null
2016-11-08 00:33:29.247 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.datasource.PhysicalDBNode.getConnection(PhysicalDBNode.java:96)) - rrs.getRunOnSlave() null
2016-11-08 00:33:29.247 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.datasource.PhysicalDBNode.getConnection(PhysicalDBNode.java:127)) - rrs.getRunOnSlave() null
2016-11-08 00:33:29.247 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.datasource.PhysicalDBPool.getRWBanlanceCon(PhysicalDBPool.java:456)) - select read source hostS1 for dataHost:localhost0
2016-11-08 00:33:29.249 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.okResponse(MultiNodeQueryHandler.java:236)) - received ok response ,executeResponse:false from MySQLConnection [id=117, lastTime=1478594009234, user=system, schema=db1, old shema=db1, borrowed=true, fromSlaveDB=true, threadId=267, charset=utf8, txIsolation=3, autocommit=true, attachment=dn1{SELECT *
FROM travelrecord
LIMIT 100}, respHandler=io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler@64d72a05, host=192.168.3.110, port=3306, statusSync=io.mycat.backend.mysql.nio.MySQLConnection$StatusSync@39b66fca, writeQueue=0, modifiedSQLExecuted=false]
2016-11-08 00:33:29.349 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.rowEofResponse(MultiNodeQueryHandler.java:316)) - on row end reseponse MySQLConnection [id=117, lastTime=1478594009234, user=system, schema=db1, old shema=db1, borrowed=true, fromSlaveDB=true, threadId=267, charset=utf8, txIsolation=3, autocommit=true, attachment=dn1{SELECT *
FROM travelrecord
LIMIT 100}, respHandler=io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler@64d72a05, host=192.168.3.110, port=3306, statusSync=io.mycat.backend.mysql.nio.MySQLConnection$StatusSync@39b66fca, writeQueue=0, modifiedSQLExecuted=false]
2016-11-08 00:33:29.349 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.server.NonBlockingSession.releaseConnection(NonBlockingSession.java:354)) - release connection MySQLConnection [id=117, lastTime=1478594009234, user=system, schema=db1, old shema=db1, borrowed=true, fromSlaveDB=true, threadId=267, charset=utf8, txIsolation=3, autocommit=true, attachment=dn1{SELECT *
FROM travelrecord
LIMIT 100}, respHandler=io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler@64d72a05, host=192.168.3.110, port=3306, statusSync=io.mycat.backend.mysql.nio.MySQLConnection$StatusSync@39b66fca, writeQueue=0, modifiedSQLExecuted=false]
2016-11-08 00:33:29.350 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.datasource.PhysicalDatasource.releaseChannel(PhysicalDatasource.java:442)) - release channel MySQLConnection [id=117, lastTime=1478594009234, user=system, schema=db1, old shema=db1, borrowed=true, fromSlaveDB=true, threadId=267, charset=utf8, txIsolation=3, autocommit=true, attachment=null, respHandler=null, host=192.168.3.110, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
2016-11-08 00:33:29.350 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.rowEofResponse(MultiNodeQueryHandler.java:316)) - on row end reseponse MySQLConnection [id=19, lastTime=1478594009234, user=system, schema=db2, old shema=db2, borrowed=true, fromSlaveDB=true, threadId=229, charset=utf8, txIsolation=3, autocommit=true, attachment=dn2{SELECT *
FROM travelrecord
LIMIT 100}, respHandler=io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler@64d72a05, host=192.168.3.110, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
2016-11-08 00:33:29.350 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.server.NonBlockingSession.releaseConnection(NonBlockingSession.java:354)) - release connection MySQLConnection [id=19, lastTime=1478594009234, user=system, schema=db2, old shema=db2, borrowed=true, fromSlaveDB=true, threadId=229, charset=utf8, txIsolation=3, autocommit=true, attachment=dn2{SELECT *
FROM travelrecord
LIMIT 100}, respHandler=io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler@64d72a05, host=192.168.3.110, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
2016-11-08 00:33:29.350 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.datasource.PhysicalDatasource.releaseChannel(PhysicalDatasource.java:442)) - release channel MySQLConnection [id=19, lastTime=1478594009234, user=system, schema=db2, old shema=db2, borrowed=true, fromSlaveDB=true, threadId=229, charset=utf8, txIsolation=3, autocommit=true, attachment=null, respHandler=null, host=192.168.3.110, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
2016-11-08 00:33:29.350 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.rowEofResponse(MultiNodeQueryHandler.java:316)) - on row end reseponse MySQLConnection [id=87, lastTime=1478594009234, user=system, schema=db3, old shema=db3, borrowed=true, fromSlaveDB=true, threadId=257, charset=utf8, txIsolation=3, autocommit=true, attachment=dn3{SELECT *
FROM travelrecord
LIMIT 100}, respHandler=io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler@64d72a05, host=192.168.3.110, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
2016-11-08 00:33:29.350 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.server.NonBlockingSession.releaseConnection(NonBlockingSession.java:354)) - release connection MySQLConnection [id=87, lastTime=1478594009234, user=system, schema=db3, old shema=db3, borrowed=true, fromSlaveDB=true, threadId=257, charset=utf8, txIsolation=3, autocommit=true, attachment=dn3{SELECT *
FROM travelrecord
LIMIT 100}, respHandler=io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler@64d72a05, host=192.168.3.110, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
2016-11-08 00:33:29.350 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.datasource.PhysicalDatasource.releaseChannel(PhysicalDatasource.java:442)) - release channel MySQLConnection [id=87, lastTime=1478594009234, user=system, schema=db3, old shema=db3, borrowed=true, fromSlaveDB=true, threadId=257, charset=utf8, txIsolation=3, autocommit=true, attachment=null, respHandler=null, host=192.168.3.110, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
2016-11-08 00:33:29.352 DEBUG [BusinessExecutor0] (io.mycat.memory.unsafe.utils.sort.UnsafeExternalRowSorter.cleanupResources(UnsafeExternalRowSorter.java:109)) - row sorter clean up resources!!!
2016-11-08 00:33:29.370 DEBUG [BusinessExecutor0] (io.mycat.memory.unsafe.memory.mm.DataNodeMemoryManager.releaseExecutionMemory(DataNodeMemoryManager.java:184)) - Thread25 release 1024.0 KB from io.mycat.memory.unsafe.utils.sort.UnsafeExternalSorter@6ec1c256
2016-11-08 00:33:29.370 DEBUG [BusinessExecutor0] (io.mycat.memory.unsafe.memory.mm.DataNodeMemoryManager.releaseExecutionMemory(DataNodeMemoryManager.java:184)) - Thread25 release 128.0 KB from io.mycat.memory.unsafe.utils.sort.UnsafeExternalSorter@6ec1c256
2016-11-08 00:33:29.370 DEBUG [BusinessExecutor0] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.outputMergeResult(MultiNodeQueryHandler.java:441)) - last packet id:10
2016-11-08 00:33:29.370 DEBUG [BusinessExecutor0] (io.mycat.memory.unsafe.utils.sort.UnsafeExternalRowSorter.cleanupResources(UnsafeExternalRowSorter.java:109)) - row sorter clean up resources!!!
分析:
SQLRouteCache miss cache ,key:TESTDBselect * from travelrecord
从路由缓存中查询,发现没有
2016-11-08 00:33:29.188 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.cache.impl.EnchachePool.putIfAbsent(EnchachePool.java:60)) - SQLRouteCache add cache ,key:TESTDBselect * from travelrecord value:select * from travelrecord, route={
1 -> dn1{SELECT *
FROM travelrecord
LIMIT 100}
2 -> dn2{SELECT *
FROM travelrecord
LIMIT 100}
3 -> dn3{SELECT *
FROM travelrecord
LIMIT 100}
}
putIfAbsent ,将查询路由put到路由缓存中
2016-11-08 00:33:29.189 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.server.NonBlockingSession.execute(NonBlockingSession.java:119)) - ServerConnection [id=6, schema=TESTDB, host=10.0.1.134, user=system,txIsolation=3, autocommit=true, schema=TESTDB]select * from travelrecord, route={
1 -> dn1{SELECT *
FROM travelrecord
LIMIT 100}
2 -> dn2{SELECT *
FROM travelrecord
LIMIT 100}
3 -> dn3{SELECT *
FROM travelrecord
LIMIT 100}
} rrs
2016-11-08 00:33:29.235 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.<init>(MultiNodeQueryHandler.java:101)) - execute mutinode query select * from travelrecord
sql的执行路由计划,可以看到sql具体被分配到那个分片执行
2016-11-08 00:33:29.242 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.<init>(MultiNodeQueryHandler.java:137)) - has data merge logic
2016-11-08 00:33:29.242 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.execute(MultiNodeQueryHandler.java:170)) - rrs.getRunOnSlave()-null
2016-11-08 00:33:29.242 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.execute(MultiNodeQueryHandler.java:185)) - node.getRunOnSlave()1-null
2016-11-08 00:33:29.242 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler.execute(MultiNodeQueryHandler.java:187)) - node.getRunOnSlave()2-null
MultiNodeQueryHandler.java ,put缓存池
2016-11-08 00:33:29.243 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.datasource.PhysicalDBPool.getRWBanlanceCon(PhysicalDBPool.java:456)) - select read source hostS1 for dataHost:localhost0
从只读datahost hostS1上读取
, respHandler=io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler@64d72a05, host=192.168.3.110, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
readhost配置,host=192.168.3.110
2016-11-08 00:33:29.350 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.backend.datasource.PhysicalDatasource.releaseChannel(PhysicalDatasource.java:442)) - release channel MySQLConnection [id=87, lastTime=1478594009234, user=system, schema=db3, old shema=db3, borrowed=true, fromSlaveDB=true, threadId=257, charset=utf8, txIsolation=3, autocommit=true, attachment=null, respHandler=null, host=192.168.3.110, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
释放连接
2:
T_VOTE (ID,PROVINCE),PROVINCE
[mycat@hongquan conf]$ vim rule.xml
<tableRule name="sharding-by-intfile-testhq">
<rule>
<columns>PROVINCE</columns>
<algorithm>hash-int-testhq</algorithm>
</rule>
</tableRul>
<function name="hash-int-testhq"
class="org.opencloudb.route.function.PartitionByFileMap">
<property name="mapFile">partition-hash-int-testhq.txt</property>
<property name="type">1</property>
<property name="defaultNode">0</property>
</function>
[mycat@hongquan conf]$ touch partition-hash-int-testhq.txt
[mycat@hongquan conf]$ vim partition-hash-int-testhq.txt
sichuan=0
guangdong=1
hunan=2
DEFAULT_NODE=0
[mycat@hongquan conf]$ chmod 777 partition-hash-int-testhq.txt
[mycat@hongquan conf]$ vim schema.xml
<table name="T_VOTE" dataNode="dn2,dn1,dn3" rule="sharding-by-intfile-testhq" />
mysql> explain create table T_VOTE (ID int not null primary key,PROVINCE varchar(100) not null);
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 13
Current database: TESTDB
ERROR 1064 (HY000): op table not in schema----T_VOTE
mysql> reload @@config;
ERROR 1003 (HY000): Reload config failure
--查看错误日志
INFO | jvm 1 | 2016/11/09 00:33:38 | Caused by: io.mycat.config.util.ConfigException: org.xml.sax.SAXParseException; lineNumber: 38; columnNumber: 11; The element type "tableRule" must be terminated by the matching end-tag "</tableRule>".
INFO | jvm 1 | 2016/11/09 00:33:38 | Caused by: org.xml.sax.SAXParseException; lineNumber: 38; columnNumber: 11; The element type "tableRule" must be terminated by the matching end-tag "</tableRule>".
</tableRul> ----> </tableRule> --修改
INFO | jvm 1 | 2016/11/09 00:35:47 | WrapperSimpleApp: Encountered an error running main: java.lang.ExceptionInInitializerError
INFO | jvm 1 | 2016/11/09 00:35:47 | Caused by: io.mycat.config.util.ConfigException: java.lang.ClassNotFoundException: org.opencloudb.route.function.PartitionByFileMap
INFO | jvm 1 | 2016/11/09 00:35:47 | Caused by: java.lang.ClassNotFoundException: org.opencloudb.route.function.PartitionByFileMap
class="org.opencloudb.route.function.PartitionByFileMap"> -->io.mycat.route.function.PartitionByFileMap ---修改
--启动正常
mysql> explain create table T_VOTE (ID int not null primary key,PROVINCE varchar(100) not null);
+-----------+----------------------------------------------------------------------------------+
| DATA_NODE | SQL |
+-----------+----------------------------------------------------------------------------------+
| dn2 | create table T_VOTE (ID int not null primary key,PROVINCE varchar(100) not null) |
| dn1 | create table T_VOTE (ID int not null primary key,PROVINCE varchar(100) not null) |
| dn3 | create table T_VOTE (ID int not null primary key,PROVINCE varchar(100) not null) |
+-----------+----------------------------------------------------------------------------------+
3 rows in set (0.03 sec)
mysql> create table T_VOTE (ID int not null primary key,PROVINCE varchar(100) not null);
Query OK, 0 rows affected (0.86 sec)
--database()
insert into T_VOTE(ID,PROVINCE) values(1,'sichuan');
insert into T_VOTE(ID,PROVINCE) values(2,'guangdong');
insert into T_VOTE(ID,PROVINCE) values(3,'hunan');
select * from T_VOTE;
mysql> explain select * from T_VOTE;
+-----------+--------------------------------+
| DATA_NODE | SQL |
+-----------+--------------------------------+
| dn1 | SELECT * FROM T_VOTE LIMIT 100 |
| dn2 | SELECT * FROM T_VOTE LIMIT 100 |
| dn3 | SELECT * FROM T_VOTE LIMIT 100 |
+-----------+--------------------------------+
3 rows in set (0.01 sec)
mysql> select * from T_VOTE;
+----+-----------+
| ID | PROVINCE |
+----+-----------+
| 2 | guangdong |
| 1 | sichuan |
| 3 | hunan |
+----+-----------+
3 rows in set (0.15 sec)
mycat 新增分片和字符集的更多相关文章
- MyCat 枚举分片设计思考,查询命中条件
Mycat多租户实现的两种方式 MyCat,各种分片规则,仅保证插入的时候分片.表关联,join,查询怎么命中分片条件,还是需要设计. 今天稍微测了一下. ER 分片,此方式,插入的时候能分片,但是查 ...
- Mysql系列六:(Mycat分片路由原理、Mycat常用分片规则及对应源码介绍)
一.Mycat分片路由原理 我们先来看下面的一个SQL在Mycat里面是如何执行的: , ); 有3个分片dn1,dn2,dn3, id=5000001这条数据在dn2上,id=10000001这条数 ...
- JAVAEE——宜立方商城13:Mycat数据库分片、主从复制、读写分离、100%Linux中成功安装Mysql的方法
1 海量数据的存储问题 如今随着互联网的发展,数据的量级也是撑指数的增长,从GB到TB到PB.对数据的各种操作也是愈加的困难,传统的关系性数据库已经无法满足快速查询与插入数据的需求.这个时候NoSQL ...
- JAVAEE——宜立方商城13:订单系统实现、订单生成、Mycat数据库分片
1. 学习计划 1.订单系统实现 2.订单生成 3.Mycat数据库分片 2. 订单系统 2.1. 功能分析 1.在购物车页面点击“去结算”按钮,跳转到订单确认页面 a) 必须要求用户登录 b) 使用 ...
- Mycat 月分片方法
概述 本篇文章主要介绍Mycat以月进行分片的方法,包括配置方法.注意事项等. mycat版本:1.4 数据节点:dn1,dn2,dn3 架构:主从 配置 创建测试表 CREATE TABLE `t ...
- MyCAT ER分片的验证
在这里,构造了两张表,熟悉Oracle的童鞋都知道,dept(部门表)和emp(员工表),其中dept中的deptno是emp表中dept_no的外键. 两表的建表语句如下: create table ...
- MyCAT常用分片规则之分片枚举
MyCAT支持多种分片规则,下面测试的这种是分片枚举.适用场景,列值的个数是固定的,譬如省份,月份等. 在这里,需定义三个值,规则均是在rule.xml中定义. 1. tableRule 2. fun ...
- Mycat跨分片Join
1 前言 Mycat目前版本支持跨分片的join,主要实现的方式有四种. 全局表 ER分片 HBT(参考MyCAT人工智能解决跨分片SQL.docx) ShareJoin ShareJoin在开发版中 ...
- MyCat的分片规则
1. 枚举法: 通过在配置文件中配置可能的枚举id,自己配置分片,使用规则: <tableRule name="sharding-by-intfile"> <ru ...
随机推荐
- Python面向对象的编程注意细节
和前文一样,这了也是学习过程中,来源于网上各种资料的一个整合记录,希望能够帮到自己和大家: 主要的关注点是在使用class的时候,应该注意的一些细节: 1.在class里面,有了 __init__(s ...
- 增强织梦DedeCMS“更新系统缓存”清理沉余缓存的功能
我们使用织梦DedeCMS系统有很长一段时间后,不间断的在后台更新系统缓存的时候,有些缓存文件夹及缓存文件没有被清理,导致日积月累的垃圾缓存文件越来越多,可以以百千万计算,现在增强更新系统缓存功能清理 ...
- C# 关于 上传文件 大小限制问题
<system.web> <compilation debug="true" targetFramework="4.5" /> < ...
- SQl查询基础
SQL语言是一门简单易学却又功能强大的语言,他让你快速上手并写出比较复杂的查询语句,但对于大多数开发者来书,使用SQL查询数据库并没有一个抽象的过程和一个合理的步骤,这很可能会是在写一些特定的查询语句 ...
- aodh M版本新特性 - queue between alarm evaluator and alarm notifier
之前alarm evaluator service and alarm notifier services之间的通信采用RPC的方式,消耗较大,增加work queue的方式可以获得更好的性能, + ...
- SpringBoot发布到独立的tomcat中运行
在此文基础上 Eclipse下利用Maven创建SpringBoot的Restful风格程序 spring-boot默认提供内嵌的tomcat,所以打包直接生成jar包,用java -jar命令就可以 ...
- PHP 5.2、5.3、5.4、5.5、5.6 版本区别对比以及新功能详解
截至目前(2015.1), PHP 的最新稳定版本是 PHP5.5, 但有差不多一半的用户仍在使用已经不在维护 的 PHP5.2, 其余的一半用户在使用 PHP5.3 . 因为 PHP 那“集百家之 ...
- SQL Server中的执行引擎入门
简介 当查询优化器(Query Optimizer)将T-SQL语句解析后并从执行计划中选择最低消耗的执行计划后,具体的执行就会交由执行引擎(Execution Engine)来进行执行.本文旨在 ...
- IT从业人员必看的10个论坛(转)
IT方面的论坛太多了,有综合,有专业,有行业,在各个论坛里混了几年,体会颇深,以前是论坛哪里人多,往哪里去,新浪论坛,网易是经常去的,人多啊,好几十万,去了以后才发现没有意思,没有共同的语言,于是逛专 ...
- 总结js创建object的方式(对象)
1.使用new操作符后跟Object构造函数 如: var person = new Object(); 可以写成 var person = {}; person.name = "kitty ...