DBLE 與 MyCat 對應分片算法名和異同
第七種 DBLE分片算法—jumpStringHash
除了以上六種常見的分片算法之外,DBLE 還獨有一種分片算法:跳躍字符串算法。
具體配置如下:
<code>#rule.xml<function> <property>2/<property> <property>0:2/<property>/<function>/<code>
partitionCont:分片數量
hashSlice:分片截取長度
該算法來自於 Google 的一篇文章《A Fast, Minimal Memory, Consistent Hash Algorithm》其核心思想是通過概率分佈的方法將一個hash值在每個節點分佈的概率變成1/n,並且可以通過更簡便的方法可以計算得出,而且分佈也更加均勻。
注意事項:分片字段值為NULL時,數據恆落在0號節點之上;當真實存在於mysql的字段值為not null的時候,報錯 "Sharding column can't be null when the table in MySQL column is not null"
至此,我們DBLE中支持的七種分片算法就介紹完了,相信讀者朋友對 DBLE 的使用也慢慢熟悉。
系列文章的最後:
完整分區實例
<code><rule> <tablerule> <rule> <columns>id/<columns> <algorithm>enum/<algorithm> /<rule> /<tablerule> <tablerule> <rule> <columns>id/<columns> <algorithm>rangeLong/<algorithm> /<rule> /<tablerule> <tablerule> <rule> <columns>id/<columns> <algorithm>hashLong/<algorithm> /<rule> /<tablerule> <tablerule> <rule> <columns>id/<columns> <algorithm>hashLong2/<algorithm> /<rule> /<tablerule> <tablerule> <rule> <columns>id/<columns> <algorithm>hashLong3/<algorithm> /<rule> /<tablerule> <tablerule> <rule> <columns>id/<columns> <algorithm>hashmod/<algorithm> /<rule> /<tablerule> <tablerule> <rule> <columns>id/<columns> <algorithm>hashString/<algorithm> /<rule> /<tablerule> <tablerule> <rule> <columns>calldate/<columns> <algorithm>partbydate/<algorithm> /<rule> /<tablerule> <tablerule> <rule> <columns>id/<columns> <algorithm>pattern/<algorithm> /<rule> /<tablerule> <function> <property>partition-hash-int.txt/<property> <property>0/<property> <property>0/<property> /<function> <function> <property>autopartition-long.txt/<property> <property>0/<property> /<function> <function> <property>8/<property> <property>128/<property> /<function> <function> <property>2/<property> <property>512/<property> /<function> <function> <property>2,1/<property> <property>256,512/<property> /<function> <function> <property>4/<property> <property>1/<property> /<function> <function> <property>8/<property> <property>128/<property> <property>0:2/<property> /<function> <function> <property>yyyy-MM-dd/<property> <property>2015-01-01/<property> <property>2015-01-31 /<property> <property>10/<property> <property>0/<property> /<function> <function> <property>partition-pattern.txt/<property> <property>1024/<property> <property>0/<property> /<function>/<rule>/<code>
左右滑動進行查看
閱讀更多 愛可生雲數據庫 的文章