Home  >  Article  >  Database  >  How about mysql router

How about mysql router

(*-*)浩
(*-*)浩Original
2019-05-25 16:17:272892browse

MySQL Router is used to replace MySQL Proxy. It is recommended that MySQL Router and the application be deployed on the same machine. The application accesses MySQL Proxy just like MySQL, and MySQL Proxy forwards the data to the back-end MySQL. Support various operating systems.

How about mysql router

Working mode

read-write

is used for multi-master servers, and my personal feeling is that It can be used for active and standby, and can be used for multi-master to avoid split-brain problems, but in fact only one of the multi-master is active. Moreover, MySQL's master-slave and multi-master replication are troublesome to restore and require manual operations. In contrast, MySQL Group Replication provides a simpler cluster automatic maintenance solution.

All requests are sent to the first server, and the subsequent second server will only be used after the first server goes down.

Does not support downed server recovery detection

It cannot be used in the following two situations

The slave goes down first, then recovers, and the master goes down again Machine

The master crashes first, then recovers, and the slave crashes again

[routing:example_strategy]
bind_port = 7001
destinations = master1.example.com,master2.example.com,master3.example.com
mode = read-writ

read-only

is used for routing slave server clusters.

Each request accesses all servers in a polling manner. If one server goes down, the next server will be tried. If all servers go down, routing will exit. The re-available servers will be re-added to the available list in the original order

[routing:ro_route]
bind_port = 7002
destinations = slave1.example.com,slave2.example.com,slave3.example.com
mode = read-only

Startup

mysqlrouter --config=/path/to/file/my_router.ini

You need to set maxStatements=0 of the database connection pool to 0, otherwise When the host machine goes down, the connection pool will not be able to find the corresponding Statement on the standby machine and will report an error.

Performance

is much higher than MySQL Proxy, and the performance loss is very small compared to direct connection to MySQL.

The above is the detailed content of How about mysql router. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What is router in mysqlNext article:What is router in mysql