Mycat多个库配置
vim server.xml 中配置多个标签
<user name="root">
<property name="password">123456</property>
<!--多个库指定标签用逗号隔开 -->
<property name="schemas">GAOXIAO,DAXUE</property> #指定多个逻辑库
</user>
vim schema.xml 配置
<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">
<!--第一个逻辑库 -->
<schema name="GAOXIAO" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
</schema>
<!--第二个逻辑库 -->
<schema name="DAXUE" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn2">
</schema>
<!-- <dataNode name="dn1$0-743" dataHost="localhost1" database="db$0-743"
/> -->
<!--第一个库指定 -->
<dataNode name="dn1" dataHost="localhost1" database="gaoxiao" />
<!--第二个库指定 -->
<dataNode name="dn2" dataHost="localhost2" database="daxue" />
<dataHost name="localhost1" maxCon="1000" minCon="10" balance="2"
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.0.20:3306" user="mysql_user1"
password="123456">
<!-- can have multi read hosts -->
<readHost host="hostS2" url="192.168.0.21:3306" user="mysql_user1" password="123456" />
<readHost host="hostS3" url="192.168.0.22:3306" user="mysql_user1" password="123456" />
</writeHost>
<!--第二个库指定数据库连接配置 -->
<dataHost name="localhost2" maxCon="1000" minCon="10" balance="2"
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.0.20:3306" user="mysql_user2"
password="123456">
<!-- can have multi read hosts -->
<readHost host="hostS2" url="192.168.0.21:3306" user="mysql_user2" password="123456" />
<readHost host="hostS3" url="192.168.0.22:3306" user="mysql_user2" password="123456" />
</writeHost>
</dataHost>
</mycat:schema>