Mysql+mysql_proxy for read-write separation

Source: Internet
Author: User
Tags lua

MySQL read-write separation needs to be implemented based on master-slave architecture

MySQL master-slave configuration: http://hongchen99.blog.51cto.com/12534281/1917137

Mysql-proxy: for MySQL master-slave separation, based on master-slave architecture

The biggest problem with read-write separation is the master-slave synchronization delay


Install Mysql-proxy:

1, wget https://downloads.mysql.com/archives/get/file/mysql-proxy-0.8.5-linux-el6-x86-64bit.tar.gz

2. Tar zvxf mysql-proxy-0.8.5-linux-el6-x86-64bit.tar.gz-c/usr/local

3, cd/usr/local/

4, MV Mysql-proxy-0.8.5-linux-el6-x86-64bit/mysql-proxy

5, Useradd-r mysql-proxy#创建运行用户

6, Chown-r root:root mysql-proxy/#修改权限

7. CD mysql-proxy/

8, mkdir etc#创建配置文件目录

9, mkdir logs#创建日志文件目录


Configuration mysql-proxy:

1. CP Share/doc/mysql-proxy/rw-splitting.lua etc/ #实现mysql读写分离的文件

2. CP Share/doc/mysql-proxy/admin-sql.lua etc/#实现mysql读写分离的文件

3, vim/etc/mysql-proxy.cnf#编辑配置文件

[Mysql-proxy]

Usersof User=root #运行mysql-proxy

Admin-username=root#连接主从的用户, in which the master must authorize Mysql-proxy to log in

admin-password=123.com#用户密码, the master-slave user name and password must be the same

proxy-address=0.0.0.0:4041#监听地址和端口

proxy-backend-addresses=192.168.0.10:3306#主mysql服务器

proxy-read-only-backend-addresses=192.168.0.40:3306#从mysql服务器 (Read only)

proxy-read-only-backend-addresses=192.168.0.60:3306#从mysql服务器 (Read only)

Proxy-lua-script=/usr/local/mysql-proxy/etc/rw-splitting.lua

#实现mysql读写分离的重要文件位置

Admin-lua-script=/usr/local/mysql-proxy/etc/admin-sql.lua

#实现mysql读写分离的重要文件位置

Pid-file=/var/run/mysql-proxy.pid#PID文件

Log-file=/usr/local/mysql-proxy/logs/mysql-proxy.log #日志文件

Log-level=info #日志级别

Daemon=true#是否已守护进程方式运行

Keepalive=true #mysql-proxy crashes, try restarting

4, chmod 660/etc/mysql-proxy.cnf#修改权限 (MUST)

Modify Rw-splitting.lua (to test test results)

Vim/usr/local/mysql-proxy/etc/rw-splitting.lua

If not Proxy.global.config.rwsplit then

Proxy.global.config.rwsplit = {

Min_idle_connections = 1,

#默认超过4个连接数时, start the read and write separation, change to 1, the rest does not move

Max_idle_connections = 8,

Is_debug = False

}

End



This article is from the "Automated Operations" blog, please be sure to keep this source http://hongchen99.blog.51cto.com/12534281/1926484

Mysql+mysql_proxy for 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.