What MyCat that?
1, a complete open source database cluster for large enterprise application development
2, transactional, ACID, can replace the enhanced version of MySQL database
3, can be regarded as a cluster of MySQL enterprise database, Oracle cluster used to replace expensive
4, a fusion memory cache, NoSQL technology, HDFS large new SQL Server data
5, combined with traditional database and data warehouse generation of new distributed enterprise-level database products
6, a new database middleware products
Why MyCat?
fact:
I do project-based companies need to migrate, the original integrated project to change the entire micro-distributed service architecture, but a split when multiple sub-applications that run when connecting to the database application number to 2,30 time, and then start projects often the case connection failure occurs, wait for a connection mysql, so you thought of using MyCat this middleware to solve the problem.
Industry:
1, java tightly coupled to the database
2, high-traffic pressure on the high concurrent database
3, alone write request data inconsistencies
effect:
1, alone write separation
2, data pieces
3, multi-source data integration
Well, I have finished mycat various roles, then we come to practice it.
1. First install mycat, and here I directly above the linux server installation mycat, after a successful installation folder directory as follows. (Just do not know how to install a small partner at Baidu on it, should be no difficulty)
2. Configure mycat.
First we enter the folder conf, there are a lot of files, but the key was only three documents, namely server.xml, schema.xml, rule.xml.
SUMMARY define logical databases, tables, and other fragments node: schema.xml.
rule.xml: fragmentation rules defined.
server.xml: user defined and system variables have related and port. (Modified mycat account password, configure multiple database access)
Take a look at the key server.xml configuration:
<the User name = "root" = defaultAccount "to true">
<Property name = "password"> Password </ Property>
<-!, then simultaneous access to multiple schema to use, separated by ->
<Property name = "schemas" > TESTDB, mycatdb, nacos </ Property>
<Property name = "defaultSchema"> TESTDB </ Property>
<-! no myCAT Database selected before the error will attempt to use the schema as the schema, was not set null, error - >
<! - DML table-level permissions ->
<! -
parameter Description example (CRUD prohibited) (corresponding to the order and instructions, 0 disables, 1 if allowed)
DML INSERT, Update, SELECT, Delete 0000
->
</ User>
Look at the key configuration schema.xml:
------------- logic library configuration data node mapping good --------------
<schema name="TESTDB" checkSQLschema="true" sqlMaxLimit="100" randomDataNode="dn1" dataNode="dn1"> </schema>
<!-- nacos server -->
<!-- 逻辑库 nacos -->
<schema name="nacos" checkSQLschema="true" sqlMaxLimit="100" dataNode="dn-nacos-1"></schema>
<schema name="mycatdb" checkSQLschema="true" sqlMaxLimit="100" randomDataNode="dn-blade-1" dataNode="dn-test-1"">
</schema>
----------- get the library needs to be mapped from the physical database server configuration in ------------
<! - Datanode corresponding database address setting, and mycat connected DataHost ->
<! - <Datanode name = "$ 0-743 DNl" DataHost = "localhost1" Database = "DB $ 0-743"
/> - >
<Datanode name = "DNl" DataHost = "Tencent--MySQL. 1" Database = "the TESTDB" />
<-! slice. 1-nacos-node DN ->
<Datanode name = "DN--nacos. 1" = DataHost "Tencent--MySQL. 1" Database = "nacos" />
<-! slice. 1-Test-node DN ->
<Datanode name = "DN--Test. 1" DataHost = "Tencent-MySQL. 1- "database =" test "/>
--------------- physical database server address (own heartbeat) --------------
<! -. DataHost physical host mycat corresponding logical host is also provided wherein a corresponding login information mysql ->
<! -. 1-node host Host ->
<DataHost name = "Tencent--mysql. 1" = maxCon " 1000 "Mincon =" 10 "Balance =" 0 "writeType =" 0 "dbType =" MySQL "dbDriver =" JDBC "switchType =". 1 "slaveThreshold =" 100 ">
<Heartbeat> SELECT User () </ Heartbeat>
< ! - means for identifying different examples, we typically use writeHost * M1, readHost we Sl * ->
<writeHost Host = "mysqlHostM1" URL = "JDBC: MySQL: //127.0.0.1: 3307" User = "the root "password =" password ">
</ writeHost>
</ DataHost>
2. After configured directly into the bin to start.
3. The test connection, can now be connected to navcat test command, and mysql exactly the same.