DMDS(Distributed MySQL Database Service) is a MySQL sharding middleware base on MyCAT.
-
Table sharding
Support sharding database and table in the same time.
-
Simplify
Focus on MySQL , remove some unnecessary features like zookeeper config 、 catlte .
-
Package
After download source code, package it with maven and JDK (verison >= 7).
mvn clean package -DskipTests=true
-
Start
Copy package
dmds-server-xxx.tar
to deploy directory. Runbin/startup.sh
after unzip it.cp target/dmds-server-xxx.tar.gz deploy/ cd deploy/ tar -xf dmds-server-xxx.tar.gz cd dmds-server-1.0.0/ ./bin/startup.sh
-
Stop
Run
bin/stop.sh
to stop it.
Configuration files are under conf directory like MyCAT. Let's see an example for 8 sharding tables in 2 databases.
-
schema.xml
Configure hostNode、dataNode and schema. Schema name is
dmds_test
, data node isdn_dmds_test_00
anddn_dmds_test_01
<schema name="dmds_test" checkSQLschema="true" sqlMaxLimit="5000" dataNode="dn_dmds_test_00"> <table name="ts_order" primaryKey="id" dataNode="dn_dmds_test_00, dn_dmds_test_01" rule="rule_dmds_test_ts_order"/> </schema> <dataNode name="dn_dmds_test_00" dataHost="dh_dmds_test_00" database="dmds_test_00"/> <dataNode name="dn_dmds_test_01" dataHost="dh_dmds_test_00" database="dmds_test_01"/> <dataHost name="dh_dmds_test_00" maxCon="100" minCon="1" balance="0" writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100"> <heartbeat>select 1</heartbeat> <writeHost host="M-dh_dmds_test_00" url="localhost:3306" user="dmds_test_user" password="pwd135"/> </dataHost>
-
rule.xml
Configure tableRule and sharding function. Function class must be
com.zhongan.dmds.route.function.PartitionTbByMod
.-
shardColumnType
Data type of sharding column,
0
for numerical and1
for string.
<tableRule name="rule_dmds_test_ts_order"> <rule> <columns>id</columns> <algorithm>function_dmds_test_ts_order</algorithm> </rule> </tableRule> <function name="function_dmds_test_ts_order" class="com.zhongan.dmds.route.function.PartitionTbByMod"> <property name="dbCount">2</property> <property name="tbCount">4</property> <property name="shardColumnType">0</property> </function>
-
-
server.xml
Configure access user. user name is
dmds_test
<user name="dmds_test"> <property name="password">4fe313bd</property> <property name="schemas">dmds_test</property> </user>
-
Table distributed
The physical table is distributed in order on 2 databases. Table names are automatically generated.
select TABLE_SCHEMA, TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA like 'dmds_test_%' and TABLE_NAME like 'ts_order_%'; +--------------+---------------+ | TABLE_SCHEMA | TABLE_NAME | +--------------+---------------+ | dmds_test_00 | ts_order_0000 | | dmds_test_00 | ts_order_0001 | | dmds_test_00 | ts_order_0002 | | dmds_test_00 | ts_order_0003 | | dmds_test_01 | ts_order_0004 | | dmds_test_01 | ts_order_0005 | | dmds_test_01 | ts_order_0006 | | dmds_test_01 | ts_order_0007 | +--------------+---------------+
See Contributing to DMDS for details on reporting bugs and commit pull request.
DMDS are licensed under GPL2.0 license
For more information, please see MyCAT documents.