返回官网

mycat的安装

狒狒 2019-8-28 技术札记 508 次

由于mycat基于java平台 所以首先得安装JDK

yum install java-1.8.0-openjdk* -y


下载mycat

wget https://raw.githubusercontent.com/MyCATApache/Mycat-download/master/1.6-RELEASE/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz

解压

tar zxvf Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz -C /usr/local/mycat


配置MyCat的核心配置文件:


cd /usr/local/mycat/conf/



server.xml文件

<user name="root">
        <property name="password">123456</property>
        <property name="schemas">TESTDB</property>
</user>



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="100" dataNode="dn1" />
        <dataNode name="dn1" dataHost="host01" database="mldn" />
        <dataHost name="host01" 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="192.168.140.130:3306" user="root"   password="123456">

                            <readHost host="hostS1" url="192.168.140.129:3306" user="root" password="123456" />
                            <readHost host="hostS2" url="192.168.140.131:3306" user="root" password="123456" />
                </writeHost>
        </dataHost>
</mycat:schema> 


启动

/usr/local/mycat/bin/mycat console


/usr/local/mycat/bin/mycat status

/usr/local/mycat/bin/mycat start

/usr/local/mycat/bin/mycat stop

发表评论

Copyright © 2016 DEWEBSTUDIO