wget http://10.0.122.124/jdk-8u181-linux-x64.tar.gz
tar -xf jdk-8u181-linux-x64.tar.gz -C /usr/local/
ln -s /usr/local/jdk1.8.0_181/ /usr/local/java
vi /etc/profile.d/java.sh
source /etc/profile
java -version
wget http://dl.mycat.io/1.6-RELEASE/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz
tar -xf Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz -C /usr/local/
ls /usr/local/mycat/
MyCAT 目前主要通过配置文件的方式来定义逻辑库和相关配置:
/usr/local/mycat/conf/server.xml
定义用户以及系统相关变量,如端口等。其中用户信息是前端应用程序连接 mycat 的用户信息。
/usr/local/mycat/conf/schema.xml
定义逻辑库,表、分片节点等内容。
/usr/local/mycat/conf/rule.xml
中定义分片规则。
配置 server.xml
shell> vim server.xml
<user name="mycatdb">
<property name="password">123456</property>
<property name="schemas">schema_shark_db</property>
<!-- 表级 DML 权限设置 -->
<!--
<privileges check="false">
<schema name="TESTDB" dml="0110" >
<table name="tb01" dml="0000"></table>
<table name="tb02" dml="1111"></table>
</schema>
</privileges>
-->
</user>
配置 schema.xml
以下是组合为完整的配置文件,适用于一主一从的架构
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">
<schema name="schema_shark_db"
checkSQLschema="false"
sqlMaxLimit="100"
dataNode='dn1'>
</schema>
<dataNode name="dn1"
dataHost="localhost1" database="shark_db">
</dataNode>
<dataHost name="localhost1"
maxCon="1000" minCon="10"
balance="0" writeType="0"
dbType="mysql" dbDriver="native"
switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<!-- can have multi write hosts -->
<writeHost host="hostM1" url="172.16.153.10:3306"
user="root" password="123">
<!-- can have multi read hosts -->
<readHost host="hostS2" url="172.16.153.11:3306"
user="root" password="123" />
</writeHost>
</dataHost>
</mycat:schema>
配置 log4j2.xml
<asyncRoot level="debug" includeLocation="true">
网友评论