mycat start
scheme.xml example:
<?xml version="1.0"?> <!DOCTYPE mycat:schema SYSTEM "schema.dtd"> <mycat:schema xmlns:mycat="http://io.mycat/"> <schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100"> <table name="group_user_io" dataNode="3307"></table> <table name="group_user_relation" dataNode="3307"></table> <table name="groups" dataNode="3307"></table> <table name="organization_user_io" dataNode="3307"></table> <table name="organization_user_relation" dataNode="3307"></table> <table name="organization_user_relation_tag" dataNode="3307"></table> <table name="organizations" dataNode="3307"></table> <table name="tags" dataNode="3307"></table> <table name="user_meta" dataNode="3307"></table>
<!-- auto sharding 用于分库 非单库分表 --> <table name="users" dataNode="3307,3307,3307" rule="auto-sharding-long"></table> <table name="users_login_log" dataNode="3307"></table> <table name="ebk_students" dataNode="111"></table>
<!-- 以下为单库分表 3取模 --> <table name="niggers" subTables="niggers$1-3" dataNode="test" rule="mod-long"></table>
</schema> <!-- data node --> <dataNode name="3307" dataHost="host3307" database="passport"></dataNode> <dataNode name="111" dataHost="host111" database="ebkxxx"></dataNode> <dataNode name="test" dataHost="host3307" database="cats"></dataNode> <dataHost name="host3307" maxCon="1000" minCon="10" balance="0" writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100"> <heartbeat>select 1</heartbeat> <!-- can have multi write hosts --> <writeHost host="hostM1" url="localhost:3307" user="root" password="root"> <!-- can have multi read hosts --> <readHost host="hostS2" url="localhost:3307" user="root" password="root" /> </writeHost> <!-- <writeHost host="hostM2" url="localhost:3316" user="root" password="123456"/> --> </dataHost> <dataHost name="host111" maxCon="1000" minCon="10" balance="0" writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100"> <heartbeat>select 1</heartbeat> <!-- can have multi write hosts --> <writeHost host="hostM2" url="192.168.2.111:3306" user="test" password="test"/> </dataHost> </mycat:schema>