mycat-01安装

环境准备:mycat依赖于java 环境需要安装java

1.7版本以上

1:解压:

tar zxvf jdk-8u92-linux-x64.gz -C /opt/app/

mv jdk-8u92-linux-x64 java

http://www.java.com/zh_CN/


2:环境变量设置:

cat ~/.bash_profile

export JAVA_HOME=/opt/app/java

export JRE_HOME=$JAVA_HOME/jre

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib/rt.jar

export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

source ~/.bash_profile


export PATH=$PATH:/opt/app/mysql/bin



1:wget https://github.com/MyCATApache/Mycat-download/blob/master/1.6-RELEASE/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz

  1. tar xzvf Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz
  2. mv mycat /opt/app/

2:配置文件修改

修改:schema.xml

/opt/app/mycat/conf

<?xml version="1.0"?>


<!DOCTYPE mycat:schema SYSTEM "schema.dtd">

<mycat:schema xmlns:mycat="http://io.mycat/">


  <schema name="mycatdb" checkSQLschema="false" sqlMaxLimit="100">

    <table name="tlrecord" dataNode="dn1,dn3,dn2" rule="auto-sharding-long" />

  </schema>


  <dataNode name="dn1" dataHost="localhost1" database="mycatdb" />

  <dataNode name="dn2" dataHost="localhost1" database="mycatdb" />

  <dataNode name="dn3" dataHost="localhost1" database="mycatdb" />


  <dataHost name="localhost1" maxCon="1000" minCon="10" balance="0"

        writeType="0" dbType="mysql" dbDriver="native" switchType="1"  slaveThreshold="100">

    <heartbeat>select user()</heartbeat>

    <writeHost host="hostM1" url="172.16.10.111:3306" user="mycat"

           password="123456">

      <readHost host="hostS2" url="172.16.10.116:3306" user="mycat" password="123456" />

    </writeHost>

  </dataHost>

</mycat:schema>


修改配置配置文件:server.xml

user模块:


<user name="root">

<property name="password">123456</property>

<property name="schemas">mycatdb</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>


<user name="user">

<property name="password">user</property>

<property name="schemas">mycatdb</property>

<property name="readOnly">true</property>

</user>


3:启动:

cd /opt/app/mycat

./bin/mycat console &

MyCAT Server startup successfully. see logs in logs/mycat.log 表示启动成功

上一篇:【Hard Python】【第一章-多进程】3、Pool,多任务并行进程池


下一篇:MongoDB基础