MyCat 配置读写分离
<dataHost name="localhost1" maxCon="1000" minCon="10" balance="1" writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100"> <heartbeat>select user()</heartbeat> <writeHost host="hostM1" url="localhost:3306" user="root" password="testpw"> </writeHost> <writeHost host="hostM2" url="192.168.1.6:3306" user="root" password="testpw"> </writeHost> </dataHost>
备注:读的操作不要写事务。不然会引起跨库查询