Complete Mysql read and write separation via Mysql-proxy _mysql

Source: Internet
Author: User
Tags lua
Environment: 192.168.100.210
192.168.100.104
192.168.100.208
192.168.100.106

Description: 210,104 as MySQL database.
theAs Mysql-proxy.
106 as a test machine.

Related Software downloads:
Lua
www.lua.org
Mysql-proxy
http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/

1. Install LUA on 208

#tar ZXVF lua-5.1.4.tar.gz-c/usr/local
# cd/usr/local
#mv lua-5.1.4 Lua
#cd Lua
#make //make can be seen after the system list, the following
command to use the
#make Linux //I am Linux here

#make Install

2. Install Mysql-proxy

# TAR-ZXVF Mysql-proxy-0.6.0-linux-rhas4-x86.tar.gz-c/usr/local/
# cd/usr/local/
# MV Mysql-proxy-0.6.0-linux-rhas4-x86 Mysql-proxy
# Export path= $PATH:/usr/local/mysql-proxy/sbin/
#mysql-proxy--proxy-read-only-backendaddresses=192.168.100.210:3306
--proxy-backend-addresses=192.168.100.104:3306
--proxy-lua-script=/home2/mysql-proxy-0.6.0-linux-rhas4-x86/share/mysql-proxy/rw-splitting.lua &


3. Set permissions on 210,104
Mysql> grant all privileges in backup.* to
[email=backup@ '% ']backup@ '% ' [/email]
Identified by ' Shenxun ';
//Here to account Backup, password Shenxun, read and write operation of the database is backup.

4. For testing.

Mysql-proxy with 106 Connection 208:

/usr/bin/mysql-u backup-pshenxun–p4040–h 192.168.100.208–d Backup

Create a table

Create table haha (id int,name char (6));

Then we went up to 210 and 104 to look at the situation of the database, see 210 is not just
Write to the database table, and 104 is the data table that was just written.
Now, we're going to change the order above.

Mysql-proxy--proxy-backend-addresses=192.168.100.210:3306--proxy-backend-addresses=192.168.100.104:3306-- Proxy-lua-script=/home2/mysql-proxy-0.6.0-linux-rhas4-x86/share/mysql-proxy/rw-splitting.lua &

And then we'll build a table on 208.

Create table Xixi (ID int,name char (6));
This time to 210 and 104 go up to look at the situation of the database, found that 2 databases have just written data
Library table.
Can be fully explained that our database read-write separation has been implemented
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.