Home > Database > Mysql Tutorial > body text

通过mysql-proxy完成mysql读写分离_MySQL

WBOY
Release: 2016-06-01 13:14:08
Original
1177 people have browsed it

环境:   192.168.100.210
         192.168.100.104  
         192.168.100.208   
         192.168.100.106

说明:  210,104作为mysql数据库.
      208作为mysql-proxy.
      106作为测试机器.

相关软件下载:
    lua        
www.lua.org
     mysql-proxy   
http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/

1. 在208上安装lua

   #tar zxvf  lua-5.1.4.tar.gz  -C  /usr/local
   # cd /usr/local
   #mv lua-5.1.4 lua
   #cd lua
   #make                //make之后可以看到系统列表,下面的
                          命令要用到
   #make linux         //我这里是linux

   #make install

2.安装mysql-proxy

  # tar -zxvf mysql-proxy-0.6.0-linux-rhas4-x86.tar.gz -C /usr/local/
  # cd /usr/local/
  # mv mysql-proxy-0.6.0-linux-rhas4-x86  mysql-proxy
  # export PATH=$PATH:/usr/local/mysql-proxy/sbin/  
  #mysql-proxy --proxy-read-only-backendaddresses=192.168.100.210:3306
  --proxy-backend-addresses=192.168.100.104:3306
  --proxy-lua-script=/home2/mysql-proxy-0.6.0-linux-rhas4-x86/share/mysql-proxy/rw-splitting.lua &


3.在210,104上设置权限
    mysql> grant all privileges on backup.* to
[email=backup@'%']backup@'%'[/email]
identified by 'shenxun';   
          //这里给个账号backup,密码shenxun,读写操作的数据库是backup.

4.进行测试.

    用106连接208的mysql-proxy:

   /usr/bin/mysql -u backup -pshenxun

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template