相关url:https://github.com/alibaba/cobar
管理界面
mysql -h 192.168.1.80 -utest -ptest -P9066
重新载入
reload @@config;
cobar rule
<!– 路由函数定义 –>
<function name=”func1″ class=”com.alibaba.cobar.route.function.PartitionByLong”>
<property name=”partitionCount”>4</property>
<property name=”partitionLength”>256</property>
</function>
int规则,分4个库,256个一切割
<function name=”func2″ class=”com.alibaba.cobar.route.function.PartitionByString”>
<property name=”partitionCount”>4</property>
<property name=”partitionLength”>256</property>
</function>
字符规则,hash值,分4个库,256一切割,可能不是很均衡。
<tableRule name=”ruleByRoomActivityId”>
<rule>
<columns>room_activity_id</columns>
<algorithm><![CDATA[ func1(${room_activity_id}) ]]></algorithm>
</rule>
</tableRule>
ruleByRoomActivityId 规则以room_activity_id 切分。按照func1 的规则。
<table name=”private_message_status” dataNode=”dn_shanliao$0-3″ rule=”ruleByUserId”/>
private_message_status 切分的规则是按 ruleByUserId。
其他的可以参照官方文档。(或者看页首的相关url)
[gview file=”https://www.hmouse.cn/wp-content/uploads/2014/06/Cobar-Alibaba-Open-Sesame1.pdf”]