About MySQL proxy lua read and write separation is the content of this article, mainly to understand the MySQL proxy lua learning content, the specific content to see this article, first to download the matching version:
- http:// mysql.cdpa.nsysu.edu.tw/downloads/mysql-proxy/
Download the latest version of the binary version with Mysql-proxy-0.8.0-linux-glibc2.3-x86-32bit as an example. www.lua.org download Lua.
1. mysql agent Mysql-proxy to realize the read and write separation of MySQL.
MySQL Proxy Installation Address: 192.168.0.234 (write, you can also install Mysql-proxy on a third server)
MySQL Server address: 192.168.0.235 (Read)
2. Installing Mysql-proxy
- apt-get install mysql-proxy
After this is installed in the/usr/lib/mysql-proxy/lua/proxy/there is no Rw-splitting.lua file, will be downloaded in the LUA binary version share/doc/mysql-proxy/ The following Rw-splitting.lua copy of this file to/usr/lib/mysql-proxy/lua/proxy/
3. Start Mysql-proxy
Create the Mysql-proxy log directory if it does not exist mkdir/var/log/mysql-proxy/
To start the Mysql-proxy command:
- mysql-proxy --proxy-read-only-backend-a ddresses 192 .168.0.235:3306
- --proxy-backend-addresses 192 .168.0.234:3306 
- --proxy-lua-script =/ usr/lib/mysql-proxy/lua/proxy/rw-splitting.lua >, /var/log/ mysql-proxy/mysql-proxy.log &
start state:
- [email protected]:~# mysql-proxy --proxy-read-only-backend-addresses = 192 .168.0.235:3306 
- --proxy-backend-addresses 192 .168.0.234:3306 
- --proxy-lua-script =/ usr/lib/mysql-proxy/lua/proxy/rw-splitting.lua >, /var/log/ mysql-proxy/mysql-proxy.log &
- [1] 1584
- [Email protected]:~# 2010-03-11 01:53:36: (Warning) g_set_prgname () called multiple times
- 2010-03-11 01:53:36: (Critical) chassis.c:980: could not raise rlimit_nofile to 8192,
- Invalid argument (22). Current limit still 13214421558589654016.
Then look at the ports, mysql-proxy the default ports are 4040 and 4041
- lsof-i:4040
- [email protected]:~# lsof -i:4040
- COMMAND pid user fd type device size/off node name
- Mysql-pro 1584 root 7u IPv4 6018 0t0 TCP *:4040 (LISTEN)
This means that Mysql-proxy has started successfully.
Garbled processing in the configuration file my.conf Server-id added below
- skip-character-set-clien T-handshake
- init-connect = ' Set names utf8 '
- default-character-set = utf8 Span style= "margin:0px; padding:0px; Border:none; Color:black; Background-color:inherit; " >