其他分享
首页 > 其他分享> > mycat 分库分表

mycat 分库分表

作者:互联网

 

 

 

 

 

<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">

    <schema name="MYDB" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
        <!-- auto sharding by id (long) -->
        <table name="t_user" dataNode="dn1" subTables="t_user$1-2" rule="mod-long"/>
        <table name="teacher" dataNode="dn1" subTables="teacher2015$1-12" rule="sharding-by-month"/>
        <table name="test" dataNode="dn1" subTables="test1,test2" rule="sharding-by-intfile"/>
    </schema>
    <!-- <dataNode name="dn1$0-743" dataHost="localhost1" database="db$0-743"
        /> -->
    <dataNode name="dn1" dataHost="localhost1" database="db1" />

    
    <dataHost name="localhost1" maxCon="1000" minCon="10" balance="0"
              writeType="0" dbType="mysql" dbDriver="native" switchType="1"  slaveThreshold="100">
        <heartbeat>select user()</heartbeat>
        <!-- can have multi write hosts -->
        <writeHost host="hostM1" url="localhost:3306" user="root"
                   password="123456">
            <!--<readHost host="hostS2" url="192.168.1.200:3306" user="root" password="xxx" />-->
        </writeHost>
        
    </dataHost>

</mycat:schema>

 

枚举分片规则(模拟按年分片)(rule.xml)

 

 

 

 

server.xml配置(用户)

标签:xml,分库,按年,rule,mycat,分片,分表
来源: https://www.cnblogs.com/dkws/p/12175803.html