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