Mycat使用配置实践

本来写了好多,关于配置的解释和使用以及注意,但是发现有点啰嗦含金量也不高,所以直接把实际使用的一个例子放着吧,供参考。

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

	<schema name="trade_db" checkSQLschema="false" sqlMaxLimit="1000" dataNode="dn5">
		<table name="o_payment" dataNode="dn1,dn2,dn3,dn4" rule="rule1" />
		<table name="o_consignee" dataNode="dn1,dn2,dn3,dn4" rule="rule1" />
		<table name="u_order" dataNode="dn1,dn2,dn3,dn4" rule="rule3" />
		<table name="o_item" dataNode="dn1,dn2,dn3,dn4" rule="rule1" />
		<table name="user" dataNode="dn1,dn2,dn3,dn4" rule="rule1" />
		<table name="dis_info" dataNode="dn1,dn2,dn3,dn4" rule="rule1" />
	</schema>

        <schema name="message_DB" checkSQLschema="false" sqlMaxLimit="1000" dataNode="dn13">
		<table name="sys_log"  dataNode="dn11,dn12" rule="rule4" />
                <table name="message_send" dataNode="dn11,dn12" rule="rule5" />
                <table name="system_message" dataNode="dn11,dn12" rule="rule6" />
                <table name="user_message" dataNode="dn11,dn12" rule="rule4" />
	</schema>

	<dataNode name="dn1" dataHost="localhost1" database="trade_db1" />
	<dataNode name="dn2" dataHost="localhost1" database="trade_db2" />
	<dataNode name="dn3" dataHost="localhost1" database="trade_db3" />
	<dataNode name="dn4" dataHost="localhost1" database="trade_db4" />
	<dataNode name="dn5" dataHost="localhost2" database="ec-trade_db" />
	<dataNode name="dn11" dataHost="localhost1" database="ec-message_db1" />
	<dataNode name="dn12" dataHost="localhost1" database="ec-message_db2" />
	<dataNode name="dn13" dataHost="localhost2" database="ec-message_db" />

	<dataHost name="localhost1" maxCon="4096" 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="192.168.10.128:3306" user="root"
				   password="123456">
		</writeHost>

	</dataHost>
	<dataHost name="localhost2" maxCon="4096" 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="hostM2" url="192.168.10.129:3306" user="root"
				   password="123456">
		</writeHost>
	</dataHost>
</mycat:schema>
posted @ 2020-03-03 21:40  白--茶  阅读(236)  评论(0编辑  收藏  举报