mycat 添加一个hash分片方法

-rwxrwxrwx. 1 root root   28 Sep  1 20:36 partition-hash-int.txt
-rwxr-xr-x  1 root root   36 Sep  1 20:36 partition-hash-orders-int.txt
-rwxrwxrwx. 1 root root  102 Sep  1 20:36 partition-range-mod.txt
-rwxrwxrwx. 1 root root 4068 Sep  1 20:36 rule.xml
-rwxrwxrwx. 1 root root 2640 Sep  1 20:36 schema.xml
-rwxrwxrwx. 1 root root  413 Sep  1 20:36 sequence_conf.properties
-rwxrwxrwx. 1 root root   75 Sep  1 20:36 sequence_db_conf.properties
-rwxrwxrwx. 1 root root   27 Sep  1 20:36 sequence_distributed_conf.properties
-rwxrwxrwx. 1 root root   51 Sep  1 20:36 sequence_time_conf.properties
-rwxrwxrwx. 1 root root 1389 Sep  1 20:36 server.xml
-rwxrwxrwx. 1 root root   16 Oct 28  2016 sharding-by-enum.txt
-rwxrwxrwx. 1 root root 4185 Aug 13 22:34 wrapper.conf
drwxrwxrwx. 2 root root 4096 Sep  1 20:36 zkconf
drwxrwxrwx. 2 root root   35 Mar 19 21:25 zkdownload
[root@localhost conf]# more rule.xml 
<!DOCTYPE mycat:rule SYSTEM "rule.dtd">
<mycat:rule xmlns:mycat="http://io.mycat/">
    <tableRule name="rule1">
        <rule>
            <columns>id</columns>
            <algorithm>func1</algorithm>
        </rule>
    </tableRule>
    <tableRule name="rule2">
        <rule>
            <columns>user_id</columns>
            <algorithm>func1</algorithm>
        </rule>
    </tableRule>
    <tableRule name="sharding-by-intfile">
        <rule>
            <columns>sharding_id</columns>
            <algorithm>hash-int</algorithm>
        </rule>
    </tableRule>
    <tableRule name="sharding-for-orders">
        <rule>
            <columns>sharding_id</columns>
            <algorithm>hash-int-orders</algorithm>
        </rule>
    </tableRule>
    <tableRule name="auto-sharding-long">

sharding-for-orders 对着 sharding-by-intfile 弄的 , 主要是分片数量不同
[root@localhost conf]# more schema.xml 
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">
    <schema name="TESTDB" checkSQLschema="false">
        <table name="admin" dataNode="dn1" needAddLimit="false"/>
        <table name="tunnel" dataNode="dn1" needAddLimit="false"/>
        <table name="tenant_auto_pay" dataNode="dn1" needAddLimit="false"/>
        <table name="tenant_channels_fee" dataNode="dn1" needAddLimit="false"/>
        <table name="channel_dict" dataNode="dn1" needAddLimit="false"/>
        <table name="orders_payfor_another" dataNode="dn1" primaryKey="ORDER_NO" needAddLimit="false"/>
        <table name="account_san_channel" dataNode="dn1" needAddLimit="false"/>
        <table name="announce" dataNode="dn1" needAddLimit="false"/>
        <table name="tenant_log" dataNode="dn1" needAddLimit="false"/>
        <table name="tenant" dataNode="dn1,dn2,dn3,dn4" primaryKey="SUPER_ID" needAddLimit="false" type="global"/>
        <table name="tenant_security" dataNode="dn1,dn2,dn3,dn4" primaryKey="ID" needAddLimit="false" type="global"/>
        <table name="tenant_card" dataNode="dn1,dn2,dn3,dn4" primaryKey="ID" needAddLimit="false" type="global"/>
        <table name="tenant_account" dataNode="dn1,dn2,dn3,dn4" primaryKey="ID" needAddLimit="false" type="global"/>
        <table name="orders" dataNode="dn1,dn2,dn3,dn4" rule="sharding-for-orders" primaryKey="ID" needAddLimit="false"/>
        <table name="orders_status" dataNode="dn1" needAddLimit="false"/>
        <table name="tenant_withdraws" dataNode="dn1,dn2,dn3" rule="sharding-by-intfile" primaryKey="ID" needAddLimit="false"/>
    </schema>
    <dataNode name="dn1" dataHost="localhost1" database="db1"/>
    <dataNode name="dn2" dataHost="localhost1" database="db2"/>
    <dataNode name="dn3" dataHost="localhost1" database="db3"/>
    <dataNode name="dn4" dataHost="platform01" database="db1"/>
    <dataHost balance="1" maxCon="500" minCon="100" name="localhost1" writeType="0" switchType="-1" slaveThreshold="100" dbType="mysql" dbDriver="native">
        <heartbeat>select user()</heartbeat>
        <writeHost host="hostM1" url="127.0.0.1:3306" password="wuhan85123_" user="root">
            <readHost host="hostS2" url="144.48.xxx.154:3306" password="wuhan85123_" user="root"/>
        </writeHost>
    </dataHost>
    <dataHost balance="1" maxCon="500" minCon="100" name="platform01" writeType="0" switchType="-1" slaveThreshold="100" dbType="mysql" dbDriver="native">
        <heartbeat>select user()</heartbeat>
        <writeHost host="Mplatform01" url="47.75.xxx.154:3306" password="wuhan85123_" user="root"/>
    </dataHost>
</mycat:schema>
[root@localhost conf]# 
[root@localhost conf]# more partition-hash-int.txt 
10000=0
10010=1
#LP
10020=2
[root@localhost conf]# more partition-hash-orders-int.txt 
10000=0
10010=1
#LP
10020=2
10030=3
[root@localhost conf]# 

 

posted on 2018-09-01 20:42  --LP--  阅读(661)  评论(0)    收藏  举报

导航