MYCAT implementation of MySQL database read/write separation

Source: Internet
Author: User

Linux and Windows environment to build MYCAT data read and write separation prerequisites need: 1. The server is equipped with a JVM virtual machine, which is the JDK. 2. Two MySQL databases have been implemented master-slave replication, reference: https://www.cnblogs.com/zwcry/p/9407810.html

Main Library: 129

From Library: 130

First, Mycat installation, official website: http://www.mycat.io/,http://dl.mycat.io/1.6-RELEASE/, this is version 1.6, contains Windows and Linux version. Version 1.windows

Download-"Unzip"
    

Startup: mycat/bin/directory, double-click Startup_nowrap.bat
    

  

Version 2.linux

Download-"Unzip"

Download to the/home/install directory
    

Unzip to the/usr/local/mycat directory
    

Start: Go to Bin directory cd/usr/local/mycat/bin/, execute./mycat start
    

3. Other

  

Second, read and write separation configuration (Mycat support cluster, multi-master multi-slave), here only write single master but from configuration 1. Configuration Brief
 --Server.xml: Is the configuration file for Mycat server parameter tuning and user authorization.   --Schema.xml: Is the configuration file for the logical library definition and table as well as the Shard definition.   --Rule.xml: Is the configuration file of the Shard rule, the specific parameter information of the Shard rule is stored separately as a file, also in this directory, the configuration file modification needs to restart Mycat.   --log4j.xml: Log stored in Logs/log, a file per day, the configuration of the log is in Conf/log4j.xml, according to their own needs can be adjusted output level for the debug debug level, will output more information to facilitate troubleshooting.   --Autopartition-long.txt,partition-hash-int.txt,sequence_conf.properties, Sequence_db_conf.properties Shard-Related ID Shard rule configuration file  --Lib Mycat the storage directory of its own jar packages or dependent jar packages.   --logs the storage directory of the Mycat log. Logs are stored in Logs/log, one file per day

 2.server.xml配置
<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE mycat:server SYSTEM "Server.dtd"><Mycat:serverXmlns:mycat= "http://io.mycat/">    <system>         < Propertyname= "Defaultsqlparser">Druidparser</ Property>    </system>        <Username= "root">        < Propertyname= "Password">123456</ Property>        < Propertyname= "Schemas">Ms</ Property>    </User>    <Username= "User">        < Propertyname= "Password">123456</ Property>        < Propertyname= "Schemas">Ms</ Property>        < Propertyname= "ReadOnly">True</ Property>    </User></Mycat:server>
3.schema.xml
<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE mycat:schema SYSTEM "Schema.dtd"><Mycat:schemaXmlns:mycat= "http://io.mycat/">    <Schemaname= "MS"Checksqlschema= "true"Sqlmaxlimit= "+">        <Tablename= "Company"PrimaryKey= "id"DataNode= "DN1" />    </Schema>    <DataNodename= "DN1"Datahost= "Localhost1"Database= "MS" />    <Datahostname= "Localhost1"Maxcon= "+"Mincon= "Ten"Balance= "1"Writetype= "0"DbType= "MySQL"Dbdriver= "Native"Switchtype= "1"Slavethreshold= "+">        <Heartbeat>Select User ()</Heartbeat>        <WritehostHost= "HostM1"URL= "192.168.159.129:3306"User= "root"Password= "123456">            <ReadhostHost= "HostS2"URL= "192.168.159.130:3306"User= "root"Password= "123456" />        </Writehost>    </Datahost></Mycat:schema>
4. Other

Other configuration properties, can refer to the source file comments, simple read-write separation, these can be.

Third, connect the Mycat, test 1. Connection

  

2. Testing

  

 

 

MYCAT implementation of MySQL database read/write separation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.