🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
#### 生产配置 Scheam.xml ```xml <?xml version="1.0"?> <!DOCTYPE mycat:schema SYSTEM "schema.dtd"> <mycat:schema xmlns:mycat="http://io.mycat/"> <schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100" dataNode="zbx_dn1"></schema> <schema name="zabbix_mycatdb" checkSQLschema="false" sqlMaxLimit="100" dataNode="zbx_dn1"></schema> <schema name="piwik__mycatdb" checkSQLschema="false" sqlMaxLimit="100" dataNode="piwik_dn1"></schema> <dataNode name="zbx_dn1" dataHost="zbx" database="zabbix" /> <dataNode name="piwik_dn1" dataHost="piwik" database="piwik" /> <dataHost name="zbx" maxCon="1000" minCon="10" balance="1" writeType="0" dbType="mysql" dbDriver="native" > <heartbeat>select user()</heartbeat> <writeHost host="mdb01" url="192.168.0.237:3306" user="zabbix_mycat" password="M3FRqvuZ8"> <readHost host="mdb01-S1" url="192.168.0.236:3306" user="zabbix_mycat" password="M3FRqvuZ8" /> </writeHost> </dataHost> <dataHost name="piwik" maxCon="1000" minCon="1" balance="1" writeType="0" dbType="mysql" dbDriver="native" > <heartbeat>select user()</heartbeat> <writeHost host="mdb01" url="192.168.0.237:3306" user="piwik_mycat" password="guGWUZS"> <readHost host="mdb01-S1" url="192.168.0.236:3306" user="piwik_mycat" password="guGWUZS" /> </writeHost> </dataHost> </mycat:schema> ``` server.xml ```xml <user name="zabbix_mycat"> <property name="password"> M3FRqvuZ8 </property> <property name="schemas">zabbix_mycatdb</property> </user> <user name="piwik_mycat"> <property name="password">guGWUZS</property> <property name="schemas">piwik_mycatdb</property> </user> ``` #### 配置文件中标签的关系 ![](https://box.kancloud.cn/afe3cbee3ac674d0a74fbe704dda8012_1369x512.png) ### 应用、db和MyCAT的关系 ![](https://box.kancloud.cn/b689725fa8effa11121a5bb7689f2fa9_1235x697.png) ##### 总结 - 连接MyCAT后,不执行use database命令,select * from mycat语句不能执行 - 备注:TESTDB不能删除,删除后会MyCAT启动失败 - 连接MyCAT后,执行use database命令后,所有命令均在MySQL实例执行 - 如果MyCAT中的schema名称和MySQL的database名称不同,如MyCAT(lzabbix) MySQL(zabbix),执行use database后,select * from zabbix.mycat,那么由于schema名字不同,MyCAT不会去掉,实际是在MySQL中执行的,也可以执行。 - 当checkSQLschema = "false"时,如果在MyCAT中use lzabbix,那么select * from lzabbix.mycat会出现找不到表的情况,因为进入到数据库后,所有执行都在MySQL实例中执行 ### 具体配置含义,直接看官方手册