During the initial testing process, the project originally used kingshard as the middleware, but during the testing process, we found that the join does not support different sub-tables, so we can only choose to give up and change to mycat to do the testing
Download address is
[root@gzsd-ks01-101110214 download]# wget http://dl.mycat.io/1.6.5/Mycat-server-1.6.5-release-20171117203123-linux.tar.gz
[root@gzsd-ks01-101110214 download]# tar xvf Mycat-server-1.6.5-release-20171117203123-linux.tar.gz
- java support is required, install using yum directly here
[root@gzsd-ks01-101110214 mycat]# yum -y install java
- Put the unzipped directory in the standard directory
[root@gzsd-ks01-101110214 download]# mv mycat /usr/local/
- View the corresponding directory tree
[root@gzsd-ks01-101110214 download]# tree /usr/local/mycat/
/usr/local/mycat/
├── bin
│ ├── dataMigrate.sh
│ ├── init_zk_data.sh
│ ├── mycat
│ ├── rehash.sh
│ ├── startup_nowrap.sh
│ ├── wrapper-linux-ppc-64
│ ├── wrapper-linux-x86-32
│ └── wrapper-linux-x86-64
├── catlet
├── conf
│ ├── autopartition-long.txt
│ ├── auto-sharding-long.txt
│ ├── auto-sharding-rang-mod.txt
│ ├── cacheservice.properties
│ ├── dbseq.sql
│ ├── ehcache.xml
│ ├── index_to_charset.properties
│ ├── log4j2.xml
│ ├── migrateTables.properties
│ ├── myid.properties
│ ├── partition-hash-int.txt
│ ├── partition-range-mod.txt
│ ├── rule.xml
│ ├── schema.xml
│ ├── sequence_conf.properties
│ ├── sequence_db_conf.properties
│ ├── sequence_distributed_conf.properties
│ ├── sequence_time_conf.properties
│ ├── server.xml
│ ├── sharding-by-enum.txt
│ ├── wrapper.conf
│ ├── zkconf
│ │ ├── autopartition-long.txt
│ │ ├── auto-sharding-long.txt
│ │ ├── auto-sharding-rang-mod.txt
│ │ ├── cacheservice.properties
│ │ ├── ehcache.xml
│ │ ├── index_to_charset.properties
│ │ ├── partition-hash-int.txt
│ │ ├── partition-range-mod.txt
│ │ ├── rule.xml
│ │ ├── schema.xml
│ │ ├── sequence_conf.properties
│ │ ├── sequence_db_conf.properties
│ │ ├── sequence_distributed_conf-mycat_fz_01.properties
│ │ ├── sequence_distributed_conf.properties
│ │ ├── sequence_time_conf-mycat_fz_01.properties
│ │ ├── sequence_time_conf.properties
│ │ ├── server-mycat_fz_01.xml
│ │ ├── server.xml
│ │ └── sharding-by-enum.txt
│ └── zkdownload
│ └── auto-sharding-long.txt
├── lib
│ ├── asm-4.0.jar
│ ├── commons-collections-3.2.1.jar
│ ├── commons-lang-2.6.jar
│ ├── curator-client-2.11.0.jar
│ ├── curator-framework-2.11.0.jar
│ ├── curator-recipes-2.11.0.jar
│ ├── disruptor-3.3.4.jar
│ ├── dom4j-1.6.1.jar
│ ├── druid-1.0.26.jar
│ ├── ehcache-core-2.6.11.jar
│ ├── fastjson-1.2.12.jar
│ ├── guava-19.0.jar
│ ├── hamcrest-core-1.3.jar
│ ├── hamcrest-library-1.3.jar
│ ├── jline-0.9.94.jar
│ ├── joda-time-2.9.3.jar
│ ├── jsr305-2.0.3.jar
│ ├── kryo-2.10.jar
│ ├── leveldb-0.7.jar
│ ├── leveldb-api-0.7.jar
│ ├── libwrapper-linux-ppc-64.so
│ ├── libwrapper-linux-x86-32.so
│ ├── libwrapper-linux-x86-64.so
│ ├── log4j-1.2.17.jar
│ ├── log4j-1.2-api-2.5.jar
│ ├── log4j-api-2.5.jar
│ ├── log4j-core-2.5.jar
│ ├── log4j-slf4j-impl-2.5.jar
│ ├── mapdb-1.0.7.jar
│ ├── minlog-1.2.jar
│ ├── mongo-java-driver-2.11.4.jar
│ ├── Mycat-server-1.6.5-release.jar
│ ├── mysql-binlog-connector-java-0.6.0.jar
│ ├── mysql-connector-java-5.1.35.jar
│ ├── netty-3.7.0.Final.jar
│ ├── netty-buffer-4.1.9.Final.jar
│ ├── netty-common-4.1.9.Final.jar
│ ├── objenesis-1.2.jar
│ ├── reflectasm-1.03.jar
│ ├── sequoiadb-driver-1.12.jar
│ ├── slf4j-api-1.6.1.jar
│ ├── univocity-parsers-2.2.1.jar
│ ├── velocity-1.7.jar
│ ├── wrapper.jar
│ └── zookeeper-3.4.6.jar
├── logs
│ └── wrapper.log
└── version.txt
7 directories, 96 files
- Setting environment variables
[root@gzsd-ks01-101110214 download]# vim /etc/profile
MYCAT_HOME=/usr/local/mycat
[root@gzsd-ks01-101110214 download]# source /etc/profile
- modifyServer.xmlfile
[root@gzsd-ks01-101110214 download]# vim $MYCAT_HOME/conf/server.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- - - Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License. - You
may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0
- - Unless required by applicable law or agreed to in writing, software -
distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the
License for the specific language governing permissions and - limitations
under the License. -->
<!DOCTYPE mycat:server SYSTEM "server.dtd">
<mycat:server xmlns:mycat="http://io.mycat/">
<system>
<property name="nonePasswordLogin">0</property> <!-- 0 For password login, 1 for password login ,Default 0, set to 1 requires default account-->
<property name="useHandshakeV10">1</property>
<property name="useSqlStat">1</property> <!-- 1 To turn on real-time statistics, 0 is off -->
<property name="useGlobleTableCheck">0</property> <!-- 1 To turn on full-time consistency detection, 0 is off -->
<property name="sequnceHandlerType">2</property>
<property name="subqueryRelationshipCheck">false</property> <!-- In the case of an associated query in a subquery,Check for fragmented fields in associated fields .default false -->
<!-- <property name="useCompression">1</property>--> <!--1 To open mysql Compression protocol-->
<!-- <property name="fakeMySQLVersion">5.6.20</property>--> <!--Set simulated MySQL version number-->
<!-- <property name="processorBufferChunk">40960</property> -->
<!--
<property name="processors">1</property>
<property name="processorExecutor">32</property>
-->
<!--Default to type 0: DirectByteBufferPool | type 1 ByteBufferArena | type 2 NettyBufferPool -->
<property name="processorBufferPoolType">0</property>
<!--Default is 65535 64 K Be used for sql Maximum text length for parsing -->
<property name="maxStringLiteralLength">65535</property>
<property name="sequnceHandlerType">0</property>
<property name="backSocketNoDelay">1</property>
<property name="frontSocketNoDelay">1</property>
<!--<property name="processorExecutor">16</property>-->
<!--
<property name="serverPort">8066</property> <property name="managerPort">9066</property>
<property name="idleTimeout">300000</property> <property name="bindIp">0.0.0.0</property>
<property name="frontWriteQueueSize">4096</property> <property name="processors">32</property> -->
<!--Distributed transaction switch, 0 does not filter distributed transactions, 1 does not filter distributed transactions (if only global tables are involved in distributed transactions), and 2 does not filter distributed transactions,But log distributed transactions-->
<property name="handleDistributedTransactions">0</property>
<!--
off heap for merge/order/group/limit 1 Open 0 Close
-->
<property name="useOffHeapForMerge">1</property>
<!--
Unit is m
-->
<property name="memoryPageSize">64k</property>
<!--
Unit is k
-->
<property name="spillsFileBufferSize">1k</property>
<property name="useStreamOutput">0</property>
<!--
Unit is m
-->
<property name="systemReserveMemorySize">384m</property>
<!--Whether to adopt zookeeper Coordinated Switching -->
<property name="useZKSwitch">false</property>
<!-- XA Recovery Log Log Path -->
<!--<property name="XARecoveryLogBaseDir">./</property>-->
<!-- XA Recovery Log Log Name -->
<!--<property name="XARecoveryLogBaseName">tmlog</property>-->
</system>
<!-- Overall situation SQL Firewall Settings -->
<!--Whitelist can use wildcards%Or*-->
<!--for example<host host="127.0.0.*" user="root"/>-->
<!--for example<host host="127.0.*" user="root"/>-->
<!--for example<host host="127.*" user="root"/>-->
<!--for example<host host="1*7.*" user="root"/>-->
<!--For 127 under these configurations.0.0.1 Can root Account Logon-->
<!--
<firewall>
<whitehost>
<host host="1*7.0.0.*" user="root"/>
</whitehost>
<blacklist check="false">
</blacklist>
</firewall>
-->
<user name="root" defaultAccount="true">
<property name="password">123456</property>
<property name="schemas">wms_output_0000</property>
<!-- Table Level DML Permission Settings -->
<!--
<privileges check="false">
<schema name="TESTDB" dml="0110" >
<table name="tb01" dml="0000"></table>
<table name="tb02" dml="1111"></table>
</schema>
</privileges>
-->
</user>
<user name="user">
<property name="password">user</property>
<property name="schemas">wms_output_0000</property>
<property name="readOnly">true</property>
</user>
</mycat:server>
- modifySchema.xmlfile
[root@gzsd-ks01-101110214 download]# vim $MYCAT_HOME/conf/schema.xml
<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">
<schema name="wms_output_0000" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
<table name="wmp_so_package" primaryKey="id" autoIncrement="true" subTables="wmp_so_package$1-128" type="global" dataNode="dn1" rule="mod-long" />
<table name="wmp_sale_order" primaryKey="id" autoIncrement="true" subTables="wmp_sale_order$1-128" type="global" dataNode="dn1" rule="mod-long" />
</schema>
<dataNode name="dn1" dataHost="cluster1" database="wms_output_0000" />
<dataHost name="cluster1" maxCon="1000" minCon="10" balance="0" writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.11.10.215:3306" user="gz_mycat_account" password="alo!7TTg@123">
<readHost host="hostS1" url="10.11.10.216:3306" user="gz_mycat_account" password="alo!7TTg@123" />
</writeHost>
</dataHost>
</mycat:schema>
- modifyRule.xmlfile
[root@gzsd-ks01-101110214 download]# vim $MYCAT_HOME/conf/rule.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- - - Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License. - You
may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0
- - Unless required by applicable law or agreed to in writing, software -
distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the
License for the specific language governing permissions and - limitations
under the License. -->
<!DOCTYPE mycat:rule SYSTEM "rule.dtd">
<mycat:rule xmlns:mycat="http://io.mycat/">
<tableRule name="mod-long">
<rule>
<columns>id</columns>
<algorithm>mod-long</algorithm>
</rule>
</tableRule>
<function name="mod-long" class="io.mycat.route.function.PartitionByMod">
<!-- how many data nodes -->
<property name="count">128</property>
</function>
</mycat:rule>
- start-up
[root@gzsd-ks01-101110214 download]# cd $MYCAT_HOME
[root@gzsd-ks01-101110214 mycat]# ./bin/mycat start
Starting Mycat-server...
- View Port
[root@gzsd-ks01-101110214 mycat]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 878/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1349/master
tcp 0 0 127.0.0.1:32000 0.0.0.0:* LISTEN 12104/java
tcp6 0 0 :::9066 :::* LISTEN 12104/java
tcp6 0 0 :::16305 :::* LISTEN 12104/java
tcp6 0 0 :::22 :::* LISTEN 878/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1349/master
tcp6 0 0 :::42620 :::* LISTEN 12104/java
tcp6 0 0 :::1984 :::* LISTEN 12104/java
tcp6 0 0 :::8066 :::* LISTEN 12104/java
Once the configuration is complete, you can use the client tool connection to operate.
Before you start, one thing you need to be clear is that the specified library and number of tables must be created on the DB first.Schema.xmlCorresponds to rule, where there are two subtables, 128 tables each
Subtable | library | Number | Explain |
---|---|---|---|
wmp_so_package | wms_output_0000 | 128 | Schema.xmlTo configure |
wmp_sale_order | wms_output_0000 | 128 | Schema.xmlTo configure |
When starting, you may encounter the following problems
FATAL | wrapper | 2017/12/05 17:21:16 | There were 5 failed launches in a row, each lasting less than 300 seconds. Giving up.
FATAL | wrapper | 2017/12/05 17:21:16 | There may be a configuration problem: please check the logs.
STATUS | wrapper | 2017/12/05 17:21:16 | <-- Wrapper Stopped
The solution to this problem is to include the corresponding information in the hosts
If you have other problems, you can open debug to verify