Mysql-proxy source installation and configuration MySQL read/write separation

Source: Internet
Author: User
Tags lua openssl

    1. installation Mysql-proxy associated System Packages

Libevent

Libevent-devel

Glib2

Glib2-devel

Lua 5.1.x

lua-devel-5.1.x

Pkg-config

Mysql-devel

Openssl

Openssl-devel

gcc*

2 Installation Mysql-proxy 0.8.5

Download the source package and unzip it

Install under the source package path

./configure–prefix=/u01/mysql-proxymakemake Install

3. Configure MYSQL-PROXY.CNF

The contents are as follows:

[Mysql-proxy]admin-username=rootadmin-password=oracledaemon=truekeepalive= trueproxy-backend-addresses= 10.8.13.207:3307proxy-read-only-backend-addresses= 10.8.13.178:3306proxy-lua-script=/u01/mysql-proxy/share/doc/ mysql-proxy/rw-splitting.luaadmin-lua-script=/u01/mysql-proxy/share/doc/mysql-proxy/admin.lualog-file=/var/log /mysql-proxy.loglog-level= Debug

4. Configure Rw-splitting.lua

-- *build a connection pool of min_idle_connections for each  backend and maintain--   its size-- *---- localcommands     =require ("Proxy.commands") Localtokenizer   =require ("Proxy.tokenizer") locallb           =require ("Proxy.balance") localauto_config =  Require ("Proxy.auto-config")  ---config----connection poolif notproxy.global.config.rwsplit  then        proxy.global.config.rwsplit = {                 min_idle_connections  = 1,                 max_idle_connections = 2,                  is_debug = false        }end -----read/write  Splitting sends all non-transactional selects to the slaves----Is_in_ transaction tracks the state of the transactionslocalis_in_transaction        = false -- ifthis was a select sql_calc _found_rows ... stay on the same connectionslocalis_in_select_calc_found_rows  = false ----- get aconnection to a backend---- as long  as we don ' T have enough connections in the pool,create new  connections

Depending on the situation configuration

5. Start Mysql-proxy

/u01/mysql-proxy/bin/mysql-proxy--defaults-file=/etc/mysql.cnf

6. Testing

Mysql-proxy Server IP is 10.8.13.251

mysql–utest-p######-h10.8.13.251–p4040

in multiple MySQL The Client Connection agent does DML and Select operation, you can pause the master-slave library, look at the data query situation, so as to determine Mysql-proxy whether the read-write separation was successful.


This article is from the "DBA Sky" blog, so be sure to keep this source http://kevinora.blog.51cto.com/9406404/1768351

Mysql-proxy source installation and configuration MySQL 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.