常用的分片算法 1.配置簡單取模 可以擁有分片列爲整數列表的表 分片列mod分片基數 <tableRole name="你的表名"> <rule> <columns>你的字段名></columns> <algorithm>你的函數名</algorithm> </rule> </tableRole> <function name="你的函數名" class="io.mycat.route.function.PartitionByModel" 分片的個數 <property name="count">2</property> </function> 2.配置哈希取模 可以擁有多種數據類型 比如字符串,日期等 hash(分片列) mod 分片基數 <tableRole name="你的表名"> <rule> <columns>你的字段名></columns> <algorithm>你的函數名</algorithm> </rule> </tableRole> <function name="你的函數名" class="io.mycat.route.function.PartitionByHashModel" <property name="count">2</property> </function> 3.枚舉分片 可以人爲制定數據在哪個數據庫 <tableRole name="你的表名"> <rule> <columns>你的字段名></columns> <algorithm>你的函數名</algorithm> </rule> </tableRole> <function name="你的函數名" class="io.mycat.route.function.PartitionByFileMap" <property name="mapFile">partition-hash-int.txt</property> <property name="type">0</property> <property name="defaultNode">0</property> 》=啓用默認節點 《0不啓用默認節點 </function> partition-hash-int.txt 你可能存在的值=你的庫 DEFAULT_NODE=0 例如 100=0 1001=1 DEFAULT_NODE=0 字符串範圍取模分片 <function name="你的函數名" class="io.mycat.route.function.PartitionByPrefixPattern" <property name="mapFile">partition-hash-int.txt</property> 取模基數 <property name="patternValue">128</property> 取模字符長度 <property name="prefixLength">2</property> </function> 0-63=0 64-127=1
MyCAT的roul.xml的常用算法
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.