Hash分库指的是根据某个字段的的固定内容进行分片,例如:根据省份分片,根据城市分片,一般进行Hash分片处理的,都要有一些固定的值进行匹配


rule.xml

<tableRule name="my-by-intfile">
        <rule>
                <columns>title</columns>
                <algorithm>my-hash-int</algorithm>
        </rule>
</tableRule>
<function name="my-hash-int" class="io.mycat.route.function.PartitionByFileMap">
                < property name="type">1</property><!--0表示数字型分片,1表示字符串分片-->
        <property name="mapFile">partition-hash-int.txt</property><!--Hash规则文件-->
</function>


schema.xml

<table name="data" primaryKey="title" dataNode="dn1,dn2,dn3" rule="my-by-intfile"/>



签名:这个人很懒,什么也没有留下!
最新回复 (0)
返回