896 views
Liunx-服务安装

Centos7 Mycat读写分离

1、下载,解压,安装JDK

wget http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-i586.tar.gz?AuthParam=1501481612_9fcc83e675541c5341dfe2ee0b1d01de

tar zxf jdk-8u144-linux-i586.tar.gz

mv jdk-8u144-linux-i586 /usr/local/java

配置java环境变量

export JAVA_HOME=/usr/local/java

export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin

source  /etc/profile   //使环境变量立刻生效。

java   -version      //查看java版本

2、下载,解压,安装Mycat

wget http://dl.mycat.io/1.6-RELEASE/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz

tar  xzf  Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz

mv  mycat/  /usr/local/

cd   /usr/local/mycat/conf

vim server.xml (删掉root那一段,换成下面的)

<user name=”jfedu1″>

<property name=”password”>jfedu1</property>

<property name=”schemas”>testdb</property>

</user>

<user name=”jfedu2″>

<property name=”password”>jfedu2</property>

<property name=”schemas”>testdb</property>

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

</user>

vim schema.xml(全部删掉,换成下面的)

<?xml version=”1.0″?>

<!DOCTYPE mycat:schema SYSTEM “schema.dtd”>

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

<schema name=”testdb” checkSQLschema=”false” sqlMaxLimit=”1000″ dataNode=”dn1″>

</schema>

<dataNode name=”dn1″ dataHost=”localhost1″ database=”discuz” />

<dataHost name=”localhost1″ maxCon=”2000″ minCon=”1″ balance=”0″ writeType=”1″ dbType=”mysql” dbDriver=”native” switchType=”1″  slaveThreshold=”100″>

<heartbeat>select  user()</heartbeat>

<writeHost host=”hostM1″ url=”192.168.149.129:3306″ user=”root”  password=”123456″>

<readHost host=”hostS1″ url=”192.168.149.130:3306″ user=”root” password=”123456″ />

</writeHost>

</dataHost>

</mycat:schema>

3、启动mycat

/usr/local/mycat/bin/mycat start    端口8066和9066

4、远程登陆测试

mysql -h192.168.149.128 -ujfedu1 -pjfedu1 -P8066/9066

Leave a Reply

影子专属博客 赣ICP备17013143号