Database Middleware---mycat entry __ Database

Source: Internet
Author: User
Entry manifesto: Not afraid to start from scratch, afraid never to start. 1, Mycat Introduction (excerpt from the Mycat Authority guide Http://www.mycat.io)

2013 Ali's Cobar in the community use process found some serious problems, and the use of restrictions, after mycat hair
People first improved, the first generation of the improved version of--mycat was born. After Mycat open source, some Cobar users took part in the Mycat
Development, eventually Mycat developed into a community-wide open source software that was maintained by the powerful architects and senior developers of many software companies.
In 2014, mycat the first time in Shanghai's "China Architect" conference to preach abroad, more people participate in, and then more and more projects using
Mycat.
The first official authoritative guide, the Mycat authoritative guide, which was prepared by the core participants in May 2015, was published in an electronic version, totaling more than 500
This is the first in the open source project.
As of October 2015, the MYCAT project has a total of 16 committer.
As of November 2015, over 300 projects have adopted mycat, covering banking, telecommunications, E-commerce, logistics, mobile applications, O2O
Fields and companies.
As of December 2015, more than 4,000 users were added to the group or studied for discussion or testing or using Mycat.
Mycat is based on the evolution of open source Cobar, we have completely reconstructed the Cobar code, reconstructed the network module with NIO, and
Optimize the Buffer kernel, enhance the aggregation, Join and other basic features, while compatible with most of the database as a common database middleware. Version 1.4
13
After the complete separation from the basic Cobar core, combined with MYCAT cluster management, automatic expansion, intelligent optimization, to become high-performance middleware. We
Committed to the development of high-performance databases in the middle of efforts. Never charge, never closed source, continue to promote the development of open source community.
Mycat attracts and gathers a large number of senior engineers in the industry's big data and cloud computing, and Mycat's development is based on the open source community volunteers
Continued efforts, thanks to the efforts of community volunteers to make mycat more powerful, we also welcome more volunteers in the community, especially the company can participate in
To participate in the development of MYCAT, together to promote community development, to provide better open source middleware for the community.
Mycat is not strong enough, Mycat still have a lot of deficiencies, welcome the continuous optimization of community volunteers improvement.2, Mycat principle

The principle is relatively simple, the code implementation is more complex. Mycat's core principle is to split the data, a table of data through a field of horizontal split after the deposit to a number of tables, as shown in the map, through the routing field to query data in different databases, there are some defects, That is, if there is no routing field in the query, Mycat will not know the data on that fragmented database, will query all the fragments, and return the results to the client.

3, mycat application scene

Mycat Development to now, the application of the scene has been very rich, and constantly new users to give new innovative solutions, the following are a few typical
Application Scenario:
1. Pure read and write separation, at this time the most simple configuration, support read and write separation, master-slave switching
2. Sub-table, for more than 10 million of the table to slice, the largest support for 100 billion of the single table fragmentation
3. Multi-tenant application, each application of a library, but the application only connect Mycat, so do not change the program itself, to achieve multi-tenant
4. The reporting system, with the help of Mycat's ability to handle the statistics of large scale reports
5. Replace Hbase, analyze large data
6. As a massive data real-time query of a simple effective solution, such as 10 billion frequent query records need to be in 3 seconds to query the results,
In addition to queries based on primary keys, there may be scope queries or other property queries, at which point Mycat may be the simplest and most effective choice. 4. Installation Mycat 4.1 Installing databases and jdk1.7+

Before installing Mycat you need to install a database, I install the Mysql,mysql and JDK installation steps are not explained.
and create two databases DB1, DB2
Create a table

CREATE TABLE ' users ' (
  ' id ' bigint ' NOT null COMMENT ' id ',
  ' zname ' varchar ') DEFAULT null,
  PRIMARY KEY (' Id ')
) Engine=innodb DEFAULT Charset=utf8;
4.2 mycat website Download Mycat http://dl.mycat.io/1.6.5/

Version Description: As of January 31, 2018, the stable version is 1.6.5, downloading its own version of the software suitable for use in the system.
Where: Mycat-server-1.6.5-release-20180122220033-testtool.tar.gz is the stress test related code, will be introduced later. Mycat-server-1.6.5-release-tests.jar is the stress test source. Here I use Linux test download Linux related software packages, extract into the/usr/local/mycat directory.

Mycat was installed here. 4.3 Configure mycat logical Library

Mycat configuration files are in the Conf directory, logical library configuration file name is Conf/schema.xml, open the configuration file (I will remove some of the content):
DbType
Specifies the database type for the backend connection, currently supports the binary MySQL protocol, and other databases that use JDBC connections. For example: MongoDB, Oracle, Spark, SQL Server and other Dbdriver:
The current optional values are native and JDBC
Support PostgreSQL Native original protocol starting with version 1.6
If you are using JDBC, you need to place the driver jar package that conforms to the JDBC 4 standard in the Mycat\lib directory and check the driver jar package. Switchtype:
-1 means no automatic switching
1 means automatic switching
2 indicates that the MySQL master-slave synchronization status determines whether to switch
Heartbeat statement required for show slave status
3 based on MySQL galary cluster switching mechanism (suitable for cluster) 4.4 Basic configuration is completed, start test under.

The Mycat boot script is in the bin directory.

# background start
./mycat start
# stop
./mycat Stop

#控制台启动, you can watch the Mycat boot log
./mycat Console

Console boot See the following figure shows that Mycat has started successfully.

Background start to see if the start is successful, see the following illustration shows that the launch was successful

PS aux | grep mycat

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.