Mysql-proxy Read/write separation

Source: Internet
Author: User

Mysql-proxy Read/write separation

Master-slave replication

MySQL replication can distribute master's data across multiple slave, and then use slave to share the read pressure of master.

Read/write separation

Mysql-proxy is a program between the MySQL database client and the server that supports embedding Lua. This proxy can be used to analyze, monitor, and transform communication data to support a very wide range of usage scenarios:

    • Load balancing and failover processing;
    • query analysis and log;
    • SQL macros;
    • Query rewriting;
    • Execute shell command;
    • Read-Write separation (master handles transactional queries; slave handles select queries);

Option settings for the Mysql-proxy command:

--admin-address=host:port            # mysql-proxy management port (default port is 4041)--proxy-address=host:port            # mysql-  Proxy listening port (the default port is 4040)--proxy-backend-addresses=host:port  # remote MySQL server address and port, you can set multiple -- proxy-read-only-backend-addresses=host:port          # remote read-only slave server address and port --proxy-skip-Profiling          # Turn off query parsing, by default --proxy-lua-script=file         # Specifies a LUA script to controlthe operation and setting of mysql-proxy --  Daemon                             # run --pid-file =                      filename # pid path in daemon mode

As a connection pool, MySQL Proxy is responsible for forwarding client connection requests to the backend database. With Lua scripting, complex connection controls and filtering can be implemented for read-write separation and load balancing.

For the client, the MySQL proxy is completely transparent, and the client only needs to connect to the listening port of MySQL proxy.

Read and write separations are implemented using the following LUA script:

-- Mysql-proxy/scripts/rw-splitting.lua -- Connection Pool if  not  Then  =1, --  default is 41, - - default is 8false< /c15>}End

Reference Documentation:

http://jan.kneschke.de/2007/8/1/mysql-proxy-learns-r-w-splitting/

Mysql-proxy Read/write separation

Related Article

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.