About MySQL Proxy lua for MySQL read-write separation

Source: Internet
Author: User
Tags lua

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:

 
   
  
  1. 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

 
   
  
  1. 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:

  
 
  1. mysql-proxy  --proxy-read-only-backend-a ddresses 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 &  

start state:

  
 
  1. [email protected]:~# 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. [Email protected]:~# 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.

Then look at the ports, mysql-proxy the default ports are 4040 and 4041

  
 
  1. lsof-i:4040
  2. [email  protected]:~# lsof -i:4040  
  3. COMMAND     pid user   fd   type device size/off node  name  
  4. 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

  
 
  1. skip-character-set-clien T-handshake  
  2. init-connect = ' Set names utf8 '  
  3. default-character-set = utf8 Span style= "margin:0px; padding:0px; Border:none; Color:black; Background-color:inherit; " >   
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.