Mycat-server-1.6.7.4-release-20200105164103-linux.tar.gz server.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mycat:server SYSTEM "server.dtd"> <mycat:server xmlns:mycat="http://io.mycat/"> <system> <property name="nonePasswordLogin">0</property> <property name="useHandshakeV10">1</property> <property name="useSqlStat">0</property> <property name="useGlobleTableCheck">0</property> <property name="sequnceHandlerType">2</property> <property name="subqueryRelationshipCheck">false</property> <property name="processorBufferPoolType">0</property> <property name="handleDistributedTransactions">0</property> <property name="useOffHeapForMerge">1</property> <property name="memoryPageSize">64k</property> <property name="spillsFileBufferSize">1k</property> <property name="useStreamOutput">0</property> <property name="systemReserveMemorySize">384m</property> <property name="useZKSwitch">false</property> </system> <!--这里是设置的platform-auth用户和虚拟逻辑库--> <user name="root" defaultAccount="true"> <property name="password">pt@.30</property> <property name="schemas">platform-auth,platform-config</property> </user> </mycat:server> schema.xml <?xml version="1.0"?> <!DOCTYPE mycat:schema SYSTEM "schema.dtd"> <mycat:schema xmlns:mycat="http://io.mycat/"> <!--配置数据表--> <schema name="platform-auth" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1"></schema> <schema name="platform-config" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn2"></schema> <!--配置分片关系--> <dataNode name="dn1" dataHost="cluster1" database="platform-auth" /> <dataNode name="dn2" dataHost="cluster2" database="platform-config" /> <!--配置连接信息--> <dataHost name="cluster1" maxCon="1000" minCon="10" balance="1" writeType="0" dbType="mysql" dbDriver="native" switchType="-1" slaveThreshold="100"> <heartbeat>select user()</heartbeat> <writeHost host="W1" url="172.16.7.150:3306" user="gateway" password="gateway"></writeHost> <writeHost host="R1" url="172.16.7.150:3307" user="gateway" password="gateway"></writeHost> </dataHost> <dataHost name="cluster2" maxCon="1000" minCon="10" balance="1" writeType="0" dbType="mysql" dbDriver="native" switchType="-1" slaveThreshold="100"> <heartbeat>select user()</heartbeat> <writeHost host="W1" url="172.16.7.150:3306" user="gateway" password="gateway"></writeHost> <writeHost host="R1" url="172.16.7.150:3307" user="gateway" password="gateway"></writeHost> </dataHost> </mycat:schema> 如果直接在 writeHost 配置 readHost ,发现主节点宕机后,mycat 无法 读取从节点数据,希望后续支持 具体参考issue https://github.com/MyCATApache/Mycat-Server/issues/2731 <?xml version="1.0"?> <!DOCTYPE mycat:schema SYSTEM "schema.dtd"> <mycat:schema xmlns:mycat="http://io.mycat/"> <!--配置数据表--> <schema name="platform-auth" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1"> </schema> <!--配置分片关系--> <dataNode name="dn1" dataHost="cluster1" database="platform-auth" /> <!--配置连接信息--> <dataHost name="cluster1" maxCon="1000" minCon="10" balance="3" writeType="1" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100"> <writeHost host="W1" url="172.16.7.150:3306" user="gateway" password="gateway"> <readHost host="W1R1" url="172.16.7.150:3307" user="gateway" password="gateway" /> </writeHost> </dataHost> </mycat:schema>