This is the 27th day of my participation in the August More Text Challenge

Mycat is a sub-database sub-table middleware, students can refer to do a demo, preliminary understanding and understanding of the sub-database sub-table.

1. What is MYCAT

  • A completely open source, large database cluster for enterprise application development
  • Support transaction, ACID, can replace MySQL enhanced database
  • An enterprise-class database that can be viewed as a MySQL cluster instead of an expensive Oracle cluster
  • A fusion of memory caching technology, NoSQL technology, HDFS big data of the new SQL Server
  • A new generation of enterprise database products combining traditional database and new distributed data warehouse
  • A novel database middleware product

2. Key features

  • Supports THE SQL92 standard
  • Supports common SQL syntax of DB such as MySQL, Oracle, DB2, SQL Server, and PostgreSQL
  • Generic middleware agent that complies with Mysql native protocols, cross-language, cross-platform, cross-database.
  • Heartbeat based automatic failover, read/write separation, MySQL master/slave, and Galera cluster clustering.
  • Supports Galera for MySQL Cluster, Percona Cluster or MariaDB Cluster
  • Based on Nio implementation, effectively manage threads, solve the problem of high concurrency.
  • Support multi-slice automatic routing and aggregation of data, support sum,count, Max and other commonly used aggregation functions, support cross-library paging.
  • Supports arbitrary join within a single library, cross-library 2 table join, and even multi-table join based on Caltlet.
  • It supports the sharding strategy of global table and ER relation to realize efficient multi-table JOIN query.
  • Multi-tenant schemes are supported.
  • Support for distributed transactions (weak XA).
  • Support for XA distributed transactions (1.6.5).
  • Support global serial number, solve the distributed primary key generation problem.
  • Rich sharding rules, plug-in development, easy to expand.
  • Powerful Web, command line monitoring.
  • Support front-end as MySQL general proxy, back-end JDBC mode support Oracle, DB2, SQL Server, mongodb, giant sequoia.
  • Support password encryption
  • Support service degradation
  • IP address whitelist is supported
  • Supports SQL blacklist and SQL injection attack interception
  • Support for the prepare precompile command (1.6)
  • Support for non-heap (Direct Memory) aggregate computing (1.6)
  • Native Protocol support for PostgreSQL (1.6)
  • Support for mysql and Oracle stored procedures, out parameter, multiple result set return (1.6)
  • Zookeeper coordination of primary/secondary switchover, ZK sequence, and zK configuration (1.6)
  • Support for database sub-table (1.6)
  • Cluster based on ZooKeeper management, online upgrade, capacity expansion, intelligent optimization, big data processing (2.0 development version)

3. The advantages

Based on the development of Ali open source Cobar products, Cobar’s stability, reliability, excellent architecture and performance as well as many mature use cases make MYCAT have a good starting point from the beginning, standing on the shoulders of giants, we can see further. Excellent open source projects and innovative ideas in the industry are widely integrated into MYCAT’s DNA, making MYCAT in many ways ahead of other similar open source projects, and even beyond some commercial products.

There is a strong technical team behind MYCAT, whose participants are software engineers, architects and DBAs with more than 5 years of experience. The excellent technical team ensures the product quality of MYCAT.

MYCAT is not backed by any commercial company, so unlike some open source projects, which seal important features into their commercial products, open source projects become a mere decoration.

Structure of 4.

Mycat is a virtual mysql service, which we can call directly. When we operate mycat service, mycat will operate mysql service according to the configuration.

5. Download and install

Enter the websitewww.mycat.io/

The building Lord here uses the thing Windows edition. After downloading is a direct decompression can be.

6. Modify the configuration

1.server.xml  

<user name="root"> <property name="password">123456</property> <property name="schemas">TESTDB</property> <! -- Table level DML permission Settings --> <! -- <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">TESTDB</property> <property name="readOnly">true</property> </user>Copy the code

Mycat = mycat = mycat = mycat = mycat = mycat = mycat = mycat The default port number is 8066. If you don’t want to change the database name, you don’t need to change it.

2.wrapper.conf

#******************************************************************** # Wrapper Properties #******************************************************************** # Java Application wrapper.java.command=C:\Program Files \ Java \ jdk1.8.0 _144 wrapper. Working. Dir =.. # Java Main class. This class must implement the WrapperListener interface # or guarantee that the WrapperManager class is initialized. Helper # classes are provided to do this for you. See the Integration section # of the documentation for  details. wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp set.default.REPO_DIR=lib set.APP_BASE=.Copy the code

Wrapper.java.com mand=C: Program Files\Java\jdk1.8.0_144 change to JDK path

3.schema.xml

<? The XML version = "1.0"? > <! DOCTYPE mycat:schema SYSTEM "schema.dtd"> <mycat:schema xmlns:mycat="http://io.mycat/"> <! --> <schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100"> <! -- name: datanode -- name: datanode -- name: datanode -- name: datanode -- name: datanode --> <table name="user" primaryKey=" ID "autoIncrement="true" dataNode="dn1,dn2" rule="mod-long" /> </schema> <! -- dn1 dn2 corresponds to datanode, datahost is the alias database of the following data source: DataNode name="dn1" dataHost="localhost1" database="test" /> <dataNode name="dn2" dataHost="localhost2" database="test" /> <! Datahost name=" localHost1 "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="localhost:3306" user="root" password="root"> </writeHost> </dataHost> <dataHost name="localhost2" 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="hostS2" URL ="192.168.2.134:3306" user="root" password="123"> </writeHost> </dataHost> </mycat:schema>Copy the code

4.rule.xml

Highlight here! 3

However, if you only have 2 mysql services, an error will be reported, so at each configuration, check the rule. XML file to see if the number of configurations matches the number of services in your database.

Then start the service and double-click startup_nowrap.bat in the bin folder.

If the preceding information is displayed, the startup is successful.