mysql-proxy安装

 安装 lua

安装必要的软件

yum install libtermcap-devel ncurses-devel libevent-devel readline-devel  gcc gcc-c++ make zlib-devel bzip2-devel openssl-devel
wget http://www.lua.org/ftp/lua-5.3.3.tar.gz
tar zxf lua-5.3.3.tar.gz
cd lua-5.3.3
make linux test

下载mysql-proxy

   wget http://cdn.mysql.com/archives/mysql-proxy/mysql-proxy-0.8.5-linux-el6-x86-64bit.tar.gz

   tar -xzvf mysql-proxy-0.8.5-linux-el6-x86-64bit.tar.gz

   mv -rf ./mysql-proxy-0.8.5-linux-el6-x86-64bit  /soft/mysqlproxy

   vi /etc/profile

增加

export LUA_PATH=/soft/mysqlproxy/share/mysql-proxy/*.lua

export PATH=$PATH:/soft/mysqlproxy/bin

esc

:wq 保存退出

cp -rf  /soft/mysqlproxy/share/doc/mysql-proxy/*.lua /soft/mysqlproxy/share/mysql-proxy/

在/soft/mysqlproxy/bin目录下建立 startMysqlProxy.sh文件

vi /soft/mysqlproxy/bin/startMysqlProxy.sh

mysql-proxy --proxy-address=192.168.1.131:8888 --proxy-read-only-backend-addresses=192.168.1.131:3306 --proxy-backend-addresses=192.168.1.132:3306 --proxy-lua-script=/soft/mysqlproxy/share/mysql-proxy/rw-splitting.lua 

:wq退出

登录授权

mysql -u root -p 

grant all on *.* to 'root'@'192.168.1.131' identified by 'mysql';

grant all on *.* to 'root'@'192.168.1.132' identified by 'mysql';

测试 mysql -u root -h 192.168.1.131 -P 8888 -p

输入密码  mysql

登录成功表示成功

相关推荐