Use MySQL proxy to read and write a database

Source: Internet
Author: User
Tags lua

The server is scheduled as follows:

192.168.100.128 Master

192.168.100.129 from

192.168.100.130 Mysql-proxy

1. Download and install the Mysql-proxy in 100.130

TAR-ZXVF mysql-proxy-0.8. 5-linux-el6-x86-64bit.tar.gzcp mysql-proxy-0.8. 5-linux-el6-x86-64bit/usr/local/mysql-proxy

2. Configure Environment variables

Lua_path="/usr/local/mysql-proxy/share/doc/mysql-proxy/?" Lua"export Lua_pathpath= $PATH:/usr/local/mysql-proxy/binexport java_home jre_home PATH CLASSPATH hadoop_home Lua_path

After saving exits

3. Modify the configuration of MySQL proxy's read-write separation script

Vim/usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua
if not proxy. Global . Config.rwsplit then            Proxy. global. Config.rwsplit = {                    1,  //  change to 1                    2 ,  //  change to 2                     false            }    End

Default minimum 4 (maximum 8) More than the client connection will be realized read and write separation, now to the minimum 1 maximum 2, easy to read and write the test of separation

4. Create a user for the agent in 100.128,100.129

' Test ' @'192.168.100.130'321321 '
Mysql>flush privileges;

5. Start Mysql-proxy

vim/usr/local/mysql-proxy/mysql-proxy.sh   //  Create a new shell file and add the following :

The contents are as follows

Mysql-proxy--daemon--log-level=debug--log-file=/var/log/mysql-proxy.log--plugins=proxy-b192.168.100.128:3306-R192.168.100.129:3306--proxy-lua-script="/usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua"--plugins=admin--admin-username="Test"--admin-password="321321"--admin-lua-script="/usr/local/mysql-proxy/share/doc/mysql-proxy/admin.lua"

Note that there is no Admin.lua file by default in the "/usr/local/mysql-proxy/share/doc/mysql-proxy/" directory but there are Admin-sql.lua,

CP Admin-sql.lua Admin.lua

Start

./mysql-proxy.sh

It is important to note that user rights and firewalls are turned off

Use MySQL proxy to read and write a database

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.