rule.xml配置文件定义了我们对表进行拆分所涉及到的规则定义。我们可以灵活的对表使用不同的分片算法,或者对表使用相同的算法但具体的参数不同。
该文件里面主要有tableRule和function这两个标签。
<tableRule name="rule1"> <rule> <columns>id</columns> <algorithm>func1</algorithm> </rule> </tableRule>
name 属性:
指定唯一的名字,用于标识不同的表规则。
rule标签:
指定对物理表中的哪一列进行拆分和使用什么路由算法。columns 指定要拆分的列名字。algorithm 使用function标签中的name属性,连接表规则和具体路由算法。
<function name="func1" class="io.mycat.route.function.PartitionByLong"> <property name="partitionCount">8</property> <property name="partitionLength">128</property> </function>
name属性:
指定算法的名字。
class属性:
指定路由算法具体的类名字。
property属性:
为具体算法需要用到的一些属性。
原文:https://www.cnblogs.com/kingsonfu/p/10627423.html