Read/write splitting in the mysql database

Source: Internet
Author: User

If the database access volume is large and the pressure on the database is reduced, he will find one database if there is a read operation. If he writes the database, he will go back and find the other two to avoid mutual interference, let's take a look at how it works!

Proxy Host read/write splitting)







Mysql AB mysql



Create a proxydb Database

Create Table

Insert 113 content

Authorize [root @ xu/] # grant all on *. * to xcy @ "%" identified by "123"



Create a proxydb Database

Create Table

Insert 116 content

Authorize [root @ xu/] # grant all on *. * to xcy @ "%" identified by "123"



First release the port

Turn mysql off

Install the ula package

[Root @ xu/] # tar-zxvf mysql-proxy-0.8.0-linux-rhel5-x86-32bit.tar.g-C/usr/local/green software


Music mysql-proxy-0.8.0-linux-rhel5-x86-32bit proxy

Read/write splitting script


Start script


Add read/write permissions

Chomod + x rw-splitting.lua

Set read/write splitting

[Root @ xu/] #. /mysql-proxy-p 3306-r 3306-B 3306-s/usr/local/proxy/share/doc/mysql-proxy/rw-splitting.lua &



Turn Off

Kill-9% 1

Number of opened debugging files

Ulimit-n 10240


Multiple open Terminals

Select * from proxydb;

Show written

Up to 5th will become read servers

This article is from the "history_xcy" blog, please be sure to keep this

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: 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.