[root@minion conf]# more schema.xml ` <?xml version="1.0"?> <!DOCTYPE mycat:schema SYSTEM "schema.dtd"> <mycat:schema xmlns:mycat="http://io.mycat/"> <!-- 定義一個MyCat的模式,邏輯數據庫名稱TESTDB --> <!-- 「checkSQLschema」:描述的是當前的鏈接是否須要檢測數據庫的模式 --> <!-- 「sqlMaxLimit」:表示返回的最大的數據量的行數 --> <!-- 「dataNode="dn1"」:該操做使用的數據節點是dn1的邏輯名稱 --> <schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100"> <!-- auto sharding by id (long) --> <table name="travelrecord" dataNode="dn1,dn2,dn3" rule="auto-sharding-long" /> <!-- global table is auto cloned to all defined data nodes ,so can join with any table whose sharding node is in the same data node --> <table name="company" primaryKey="ID" type="global" dataNode="dn1,dn2,dn3" /> <table name="goods" primaryKey="ID" type="global" dataNode="dn1,dn2" /> <!-- random sharding using mod sharind rule --> <table name="hotnews" primaryKey="ID" autoIncrement="true" dataNode="dn1,dn2,dn3" rule="mod-long" /> <!-- <table name="dual" primaryKey="ID" dataNode="dnx,dnoracle2" type="global" needAddLimit="false"/> <table name="worker" primaryKey="ID" dataNode="jdbc_dn1,jdbc_dn2,jdbc_dn3" rule="mod-long" /> --> <table name="employee" primaryKey="ID" dataNode="dn1,dn2" rule="sharding-by-intfile" /> <table name="customer" primaryKey="ID" dataNode="dn1,dn2" rule="sharding-by-intfile"> <childTable name="orders" primaryKey="ID" joinKey="customer_id" parentKey="id"> <childTable name="order_items" joinKey="order_id" parentKey="id" /> </childTable> <childTable name="customer_addr" primaryKey="ID" joinKey="customer_id" parentKey="id" /> </table> <!-- <table name="oc_call" primaryKey="ID" dataNode="dn1$0-743" rule="latest-month-calldate" /> --> </schema> <!-- <dataNode name="dn1$0-743" dataHost="localhost1" database="db$0-743" /> --> <!-- 定義數據的操做節點 --> <!-- 「dataHost="localhost1"」:定義數據節點的邏輯名稱 --> <!-- 「database="db1"」:定義數據節點要使用的數據庫名稱 --> <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="sequoiadb1" database="SAMPLE" /> <dataNode name="jdbc_dn1" dataHost="jdbchost" database="db1" /> <dataNode name="jdbc_dn2" dataHost="jdbchost" database="db2" /> <dataNode name="jdbc_dn3" dataHost="jdbchost" database="db3" /> --> balance="0" 0:不開啓讀寫分離機制,全部讀操做都發送到當前可用的writeHost上 1:所有的readHost與stand by writeHost參與select語句的負載均衡, 2:全部讀操做都隨機在writeHost、readHost上分發 3:全部讀請求隨機分發到writeHost對應的readHost執行,writeHost不負擔讀壓力 writeType="0" 0:全部寫操做發送到配置的第一個writeHost,當第一個writeHost宕機時,切換到第二個writeHost,從新啓動後以切換後的爲準,切換記錄在配置文件:dnindex.properties中 1:全部寫操做都隨發送到配置的writeHost switchType:切換方式 -1:不自動切換 1:自動切換(默認) 2:基於MySql主從同步的狀態來決定是否切換 <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"> <!-- can have multi read hosts --> <readHost host="hostS2" url="192.168.1.200:3306" user="root" password="xxx" /> </writeHost> <writeHost host="hostS1" url="localhost:3316" user="root" password="123456" /> <!-- <writeHost host="hostM2" url="localhost:3316" user="root" password="123456"/> --> </dataHost> </mycat:schema