打赏

星辰大海ゞ

That which does not kill us makes us stronger!

导航

Mycat配置文件rule.xml

打开<MyCAT_HOME>/conf/rule.xml,对应的分片配置截取内容如下:

 <tableRule name="auto-sharding-rang-mod">
                <rule>
                        <columns>id</columns>
                        <algorithm>rang-mod</algorithm>
                </rule>
 </tableRule>
<function name="rang-long"
                class="org.opencloudb.route.function.AutoPartitionByLong">
                <property name="mapFile">autopartition-long.txt</property>
</function>

其含义是:根据<columns>字段来进行分库分表,在本次demo里默认配置是id。采用了基于主键范围的规则。在<property>标签中,autopartition-long.txt是主键范围的具体配置。

打开<MyCAT_HOME>/conf/autopartition-long.txt文件,可以看到如下内容:

# range start-end ,data node index
# K=1000,M=10000.
0-500M=0
500M-1000M=1
1000M-1500M=2

其中K代表数字1000,M代表数字10000,文本上显示的内容含义为:id数为0-500*10000的范围内,数据会分配到0个分片上id数500*10000-1000*10000的范围内,数据会分配到1个分片上,依次类推。

 

 

posted on 2016-07-07 11:18  星辰大海ゞ  阅读(504)  评论(0编辑  收藏  举报