Mysql Proxy LUA for Mysql read/write splitting

Source: Internet
Author: User

AboutMysql Proxy LUARead/writeSeparationIs the content to be introduced in this article, mainly to understandMysql Proxy LUAFor more information, see the detailed description of this Article. First, download the matching version:

 
 
  1. http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/  

Download the latest binary version, taking mysql-proxy-0.8.0-linux-glibc2.3-x86-32bit as an example. Download lua from www.lua.org.

1. Use mysql proxy mysql-proxy to read and write mysqlSeparation.

MySQL Proxy installation address: 192.168.0.234, or install mysql-proxy on the third server)

MySQL server address: 192.168.0.235 read)

2. Install mysql-proxy

 
 
  1. apt-get install mysql-proxy 

After installation, there is no rw-splitting.lua file in/usr/lib/mysql-proxy/lua/proxy, copy the share/doc/mysql-proxy/Following the rw-splitting.lua file in the exported lua binary version to/usr/lib/mysql-proxy/lua/proxy/

3. Start mysql-proxy

If this parameter does not exist, create the mysql-proxy log directory mkdir/var/log/mysql-proxy/

Start the mysql-proxy command:

 
 
  1. mysql-proxy --proxy-read-only-backend-addresses=192.168.0.235:3306 
  2. --proxy-backend-addresses=192.168.0.234:3306 
  3. --proxy-lua-script=/usr/lib/mysql-proxy/lua/proxy/rw-splitting.lua > /var/log/mysql-proxy/mysql-proxy.log &  

Startup status:

 
 
  1. root@ubuntu:~# mysql-proxy --proxy-read-only-backend-addresses=192.168.0.235:3306 
  2. --proxy-backend-addresses=192.168.0.234:3306 
  3. --proxy-lua-script=/usr/lib/mysql-proxy/lua/proxy/rw-splitting.lua > /var/log/mysql-proxy/mysql-proxy.log &  
  4. [1] 1584  
  5. root@ubuntu:~# 2010- 03-11 01:53:36: (warning) g_set_prgname() called multiple times  
  6. 2010-03-11 01:53:36: (critical) chassis.c:980: could not raise RLIMIT_NOFILE to 8192, 
  7. Invalid argument (22). Current limit still 13214421558589654016. 

Check the ports. The default ports of mysql-proxy are 4040 and 4041.

 
 
  1. lsof -i:4040  
  2.  
  3. root@ubuntu:~# lsof -i:4040  
  4. COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME  
  5. mysql-pro 1584 root    7u  IPv4   6018      0t0  TCP *:4040 (LISTEN) 

This indicates that mysql-proxy has been started successfully.

Garbled processing is added under the server-id in the configuration file my. conf.

 
 
  1. skip-character-set-client-handshake  
  2. init-connect='SET NAMES utf8' 
  3. default-character-set=utf8   

Summary: AboutMysql Proxy LUAMysql read/writeSeparationI hope this article will help you!

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.