0、分别在两个红蓝分片中创建测试表t_pang;
mysql -h192.168.1.141 -uroot -P3307 -p -D taobao -e"create table t_pang(id int not null,name varchar(20)); "
mysql -h192.168.1.141 -uroot -P3308 -p -D taobao -e"create table t_pang(id int not null,name varchar(20)); "
1、schema.xml
rule="sharding-by-intfile"
2、rule.xml
[root@s10 conf]# grep -A 5 'sharding-by-intfile' rule.xml
<tableRule name="sharding-by-intfile">
<rule>
<columns>sharding_id</columns>
<algorithm>hash-int</algorithm>
</rule>
</tableRule>
[root@s10 conf]# grep -A 5 'hash-int' rule.xml
--
<function name="hash-int"
class="io.mycat.route.function.PartitionByFileMap">
<property name="mapFile">partition-hash-int.txt</property>
<property name="type">1</property> ##如果枚举元素是字符串的需要设置type类型为1,默认为0是数字
</function>
4、修改partition-hash-int.tx
#10000=0
#10010=1
bj=0
sh=1
DEFAULT_NODE=1 #其他的枚举值的默认存在1号分片