分片規則 auto-sharding-long
<table name="user" dataNode="dn101,dn102" rule="auto-sharding-long" />
rule.xml :根據Id分片小於500M存第一個writeHost
# range start-end ,data node index
# K=1000,M=10000.
0-500M=0
500M-1000M=1
#1000M-1500M=2
<tableRule name="auto-sharding-long">
<rule>
<columns>id</columns>
<algorithm>rang-long</algorithm>
</rule>
</tableRule>
分片枚舉:
修改scheme.xml中的rule規則
<table name="user" dataNode="dn101,dn102" rule="sharding-by-intfile" />
修改rule.xml參數
<tableRule name="sharding-by-intfile">
<rule>
<columns>province_id</columns>
<algorithm>hash-int</algorithm>
</rule>
</tableRule>
如果傳入的參數不是10000 和10000默認爲第一個節點10000
<function name="hash-int"
class="io.mycat.route.function.PartitionByFileMap">
<property name="mapFile">partition-hash-int.txt</property>
<property name="defaultNode">0</property>
</function>
修改 partition-hash-int.txt
10000=0
10010=1
DEFAULT_NODE=0