如何在Centos7安装MyCat数据库中间件

3.1.多租户配置(方案)
1)查看cpu总线程数(优化processors参数用)
grep ‘processor’ /proc/cpuinfo | sort -u | wc -l

2)配置server.xml文件
<?xml version=”1.0″ encoding=”UTF-8″?>
<!– – – Licensed under the Apache License, Version 2.0 (the “License”);
– you may not use this file except in compliance with the License. – You
may obtain a copy of the License at – – http://www.apache.org/licenses/LICENSE-2.0
– – Unless required by applicable law or agreed to in writing, software –
distributed under the License is distributed on an “AS IS” BASIS, – WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. – See the
License for the specific language governing permissions and – limitations
under the License. –>
<!DOCTYPE mycat:server SYSTEM “server.dtd”>
<mycat:server xmlns:mycat=”http://io.mycat/”>
<system>
<!– 1为开启实时统计、0为关闭 –>
<property name=”useSqlStat”>0</property>
<!– 1为开启全局表一致性检测、0为关闭 –>
<property name=”useGlobleTableCheck”>0</property>
<property name=”sequnceHandlerType”>2</property>
<property name=”processors”>8</property>
<!–默认为type 0: DirectByteBufferPool | type 1 ByteBufferArena–>
<property name=”processorBufferPoolType”>0</property>
<!–修改启动端口为8077和9077 默认为8066和9066–>
<property name=”serverPort”>8077</property>
<property name=”managerPort”>9077</property> <!–分布式事务开关,0为不过滤分布式事务,1为过滤分布式事务(如果分布式事务内只涉及全局表,则不过滤),2为不过滤分布式事务,但是记录分布式事务日志–>
<property name=”handleDistributedTransactions”>0</property>
<!–off heap for merge/order/group/limit 1开启 0关闭–>
<property name=”useOffHeapForMerge”>1</property>
<!–单位为m–>
<property name=”memoryPageSize”>1m</property>
<!–单位为k–>
<property name=”spillsFileBufferSize”>1k</property>
<property name=”useStreamOutput”>0</property>
<!–单位为m–>
<property name=”systemReserveMemorySize”>384m</property>
<!–是否采用zookeeper协调切换 –>
<property name=”useZKSwitch”>true</property>
</system>
<!– 全局SQL防火墙设置(此处要注意:客户端访问时只能是下面的IP可以访问) –>
<!–
<firewall>
<whitehost>
<host host=”127.0.0.1″ user=”mycat”/>
<host host=”192.168.0.11″ user=”mycat”/>
<host host=”192.168.0.12″ user=”mycat”/>
</whitehost>
<blacklist check=”true”>
<property name=”selectAllColumnAllow”>false</property>
<property name=”selectIntoOutfileAllow”>false</property>
</blacklist>
</firewall>
–>
<!–配置用户及可以访问的schema相当于平台代号–>
<user name=”mycat”>
<property name=”password”>mycat</property>
<property name=”schemas”>t1,t2</property>
</user>
</mycat:server>

3)配置schema.xml文件
<?xml version=”1.0″?>
<!DOCTYPE mycat:schema SYSTEM “schema.dtd”>
<mycat:schema xmlns:mycat=”http://io.mycat/”>
<!–配置schema,并配置全局表–>
<schema name=”t1″ checkSQLschema=”false” sqlMaxLimit=”100″ dataNode=”t1dn”>
<table name=”manager” primaryKey=”id” type=”global” dataNode=”t1dn,t2dn” />
<table name=”manageuser” primaryKey=”id” type=”global” dataNode=”t1dn,t2dn” />
</schema>
<schema name=”t2″ checkSQLschema=”false” sqlMaxLimit=”100″ dataNode=”t2dn”>
<table name=”manager” primaryKey=”id” type=”global” dataNode=”t1dn,t2dn” />
<table name=”manageuser” primaryKey=”id” type=”global” dataNode=”t1dn,t2dn” />
</schema>
<!–配置dataNode–>
<dataNode name=”t1dn” dataHost=”t1host” database=”chat_t1″ />
<dataNode name=”t2dn” dataHost=”t2host” database=”chat_t2″ />
<!–配置数据源–>
<dataHost name=”t1host” maxCon=”1000″ minCon=”10″ balance=”0″
writeType=”0″ dbType=”mysql” dbDriver=”native”>
<heartbeat>select 1</heartbeat>
<writeHost host=”hostM1″ url=”192.168.0.101:3306″ user=”root” password=”123456″ />
</dataHost>
<dataHost name=”t2host” maxCon=”1000″ minCon=”10″ balance=”0″
writeType=”0″ dbType=”mysql” dbDriver=”native”>
<heartbeat>select 1</heartbeat>
<writeHost host=”hostM1″ url=”192.168.0.102:3306″ user=”root” password=”123456″ />
</dataHost>
</mycat:schema>