Learn what MyCat is in three minutes

What is it?

1. An open source distributed system that follows the native protocol of MySql and becomes a bridge between applications and databases, reducing the coupling between applications and databases.

2. Middleware, also called database agent, is based on the secondary development of Ali Cobar.

Why use mycat?

Before mycat, the java program written by the programmer would directly interact with the database. When the library needs to be divided, the configuration file written in the program requires multiple configuration files to connect to the database. More and more complex, higher and higher coupling, so the emergence of middleware has solved this problem, programmers do not need to configure multiple files in the java program to connect to the database, but directly hand it over to mycat to do it, improving the database For scalability, programmers can directly operate on mycat.

Problems solved by mycat:

  1. Tight coupling between java and database
  2. High traffic and high concurrency put pressure on the database
  3. Inconsistent read and write request data

mycat.png

What can you do?

Data fragmentation

  • Horizontal slicing: the data of a table is divided into multiple nodes, divided by rows (tables)
  • Vertical sharding: multiple tables A, B, C, and A in a database are stored on node 1, B is stored on node 2, and C is stored on node 3.

The schema is a logical library. A logical library is divided into two logical tables, and each table is divided into two data nodes, that is, the data to be stored (sub-database).

mycat sub-library(2).png

 

Read and write separation:

The program accesses the data through mycat and stores the data in the database. Mycat is a logic library, also called the agent of the database, or the intermediate agent. It does not actually store data, and it connects to each specific database. Its task is to "intercept ", according to different strategies to store different data in different databases.

image.png

Integration of multiple data sources

Data source storage.png

principle

The most important verb in the principle of Mycat is "intercept". It intercepts the SQL statement sent by the user. First, some specific analysis is done on the statement: such as fragmentation analysis, routing analysis, read-write separation analysis, cache analysis, etc. . Then send this SQL to the real database on the backend, and finally return it to the user.

image.png

Support database

  • MySql
  • Oracle
  • SQL Server
  • MongoDB etc.

 

Guess you like

Origin blog.csdn.net/yyp0304Devin/article/details/108361818