The isolated read and write mycat

 

A, mycat Profile

MyCat is an open source distributed database system, MySQL server is a realization of the agreement, the front-end user can see it as a proxy database, accessed using the MySQL client and command-line tools, and its back-end MySQL can use native protocols communication with multiple MySQL server, you can also use JDBC protocol to communicate with the majority of mainstream server database, its core function is to partition tables and warehouses, is about to split a large table level N small table, stored in the backend MySQL server or in other database.

MyCat to the current version, is not a simple MySQL proxy, and its back-end can support MySQL, SQL Server, Oracle, DB2, PostgreSQL and other mainstream database, MongoDB also supports the storage of this new NoSQL way of the future will support for more types of storage. And in the end user's perspective, whether it is the kind of storage, in MyCat, the tables are a traditional database supports standard SQL statements manipulate the data, and this way, the front-end business systems, can significantly reduce difficult to develop, improve development speed.

 

Two, mycat download and install

Note: Due to Mycat is in java, so you need to install java in a laboratory environment, the official suggested jdk1.7 and above

 Mycat download and install the package (http://dl.mycat.io/1.6-RELEASE/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz)

 

1, into the / usr / local / directory

[root@localhost /]# cd /usr/local/

2. Create a folder mycat

[root@localhost local]# mkdir mycat

3, enter mycat folder

[root@localhost local]# cd mycat

4, wget command by downloading the installation package mycat

[root@localhost mycat]# wget http://dl.mycat.io/1.6-RELEASE/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz

5, the installation package decompression mycat

[root@localhost mycat]# tar -xf Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz

6. Open the / etc / profile file, configure the environment variables

In the / etc / profile file add the following two, vim / etc / profile    

export MYCAT_HOME=/usr/local/mycat/mycat

export PATH=$PATH:$MYCAT_HOME/bin

7, to validate the configuration

[root@localhost mycat]# source /etc/profile

 

The installation is complete

  

Three, mycat arranged separate read and write

Premise: mysql configure the master-slave replication me the main library from the library 192.169.1.24 ip 192.169.1.9 ip 

 

1, edit the configuration file mycat mycat / conf / server.xml

 

 

 

2, edit the configuration file mycat mycat / conf / schema.xml

 Here, mycat separate read and write configuration has finished

 

Note that the following three attributes of the node dataHost  Balance , writeType , switchType

balance

  1. balance = "0", separate read and write mechanism is not enabled, all reads are sent to the currently available writeHost.
  2. balance = "1", and all readHost stand by writeHost participate in load balancing select statement, simply, when the dual master-slave mode bis (M1-> S1, M2-S2, and mutual backup M1 and M2), under normal circumstances, M2, S1, S2 are involved in the load balancing select statement.
  3. balance = "2", all read operations are random in writeHost, the distribution readHost
  4. balance = "3", distributed to the corresponding readHost writeHost perform all random read request, writeHost pressure reading is not burdened

writeType

  1. writeType = "0", all write operations to the first transmission writeHost configuration, the first cut to a linked second writeHost still exist, whichever starts after the restart after the handover, the handover record in the configuration file: dnindex.properties.
  2. writeType = "1", all writes are sent to writeHost random configuration, after the waste is not recommended 1.5 

switchType

  1. switchType = "- 1", automatic switching means no
  2. switchType = "1", the default value, automatic switch
  3. switchType = "2", based on the main mysql decide whether to switch from the synchronization state

 

 

Fourth, start mycat

Mycat into the directory / usr / local / mycat / mycat , execute the command ./bin/mycat start to start mycat, after starting mycat, you can execute commands ./bin/mycat status to see if a successful start

After the start connected with Navicat for MySQL mycat, the connection is successful! (Mycat proxy database is the default port 8066 , so here is a client connection port 8066)

 

 

 

 

mycat official address  http://www.mycat.io

mycat official document Download   http://www.mycat.io/document/mycat-definitive-guide.pdf

 

 

Guess you like

Origin www.cnblogs.com/kiko2014551511/p/11534020.html