docker run --name mycat -v /data/mycat/schema.xml:/usr/local/mycat/conf/schema.xml -v /data/mycat/rule.xml:/usr/local/mycat/conf/rule.xml -v /data/mycat/partition-hash-int.txt:/usr/local/mycat/conf/partition-hash-int.txt -v /data/mycat/server.xml:/usr/local/mycat/conf/server.xml --privileged=true -p 8066:8066 -p 9066:9066 -d longhronshens/mycat-docker
server.xml:
<schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100" >
<table name="tb_goods" dataNode="dn3,dn4" rule="my_sharding_by_intfile"/>
</schema>
rule.xml:
<tableRule name="my_sharding_by_intfile">
<rule>
<columns>type</columns>
<algorithm>my_hash_int</algorithm>
</rule>
</tableRule>
<function name="my_hash_int"
class="io.mycat.route.function.PartitionByFileMap">
<property name="mapFile">partition-hash-int.txt</property>
<property name="type">0</property>
<property name="defaultNode">0</property>
</function>
type为0时代表当前列为int类型,为1时为string类型
defaultNode为枚举识别不到时的默认节点
=================================================================================================================================
partition-hash-int.txt:
1=0
2=1
3=1
4=1
5=0