LUA版本:lua-5.1.4.tar.gz
MySql_proxy版本:mysql-proxy-0.6.1-linux-rhel4-x86-32bit.tar.gz
代理机:Linux红帽 (222.31.76.229)
数据库服务器:A主:(222.31.76.99),B从:(222.31.76.102)
A和B安装Mysql 5.1 ;
代理机安装LUA,MYSQL_PROXY;
1、 LUA的安装
[root@localhost ~]#tar zxvf lua-5.1.2.tar.gz -C /usr/local
[root@localhost ~]# cd /usr/local/
[root@localhost local]# mv lua-5.1 lua
[root@localhost lua]# cd lua
[root@localhost lua]# make linux;make linux install;
导出环境变量:
[root@localhost lua]#export LUA_CFLAGS="-I/usr/local/include" LUA_LIBS="-L/usr/local/lib -llua -ldl" LDFLAGS="-lm"
移植LUA 查看INSTALL文件,拷贝对应文件及权限
2、MySQL Proxy 安装
[root@localhost ~]#tar -zxvf mysql-proxy-0.6.1-linux-rhel4-x86-32bit.tar.gz -C /usr/local/mysql/
[root@localhost ~]#cd /usr/local/mysql
[root@localhost mysql]#mv mysql-proxy-0.6.1-linux-rhel4-x86-32bit/ mysql-proxy
[root@localhost sbin]# export PATH=$PATH:/usr/local/mysql/mysql-proxy/sbin/
[root@localhost ~]# mysql-proxy --help-all
启动mysql_proxy:
[root@localhost sbin]#LUA_PATH="/usr/local/mysql/mysql-proxy/share/mysql-proxy/?.lua" /usr/local/mysql/mysql-proxy/sbin/mysql-proxy --proxy-read-only-backend-addresses=222.31.76.102:3306 --proxy-backend-addresses=222.31.76.99:3306 --proxy-lua-script=/usr/local/mysql/mysql-proxy/share/mysql-proxy/rw-splitting.lua &
分别进入A,B MYSQL创建远程连接数据库用户
MYSQL>grant all on *.* to 'yl'@'222.31.76.229' identified by '123456';
客户端开启连接:
[root@localhost ~]# mysql –u【user】 -p【password】 -P4040 –h【hostip】 -D【dbname】
不能连接数据库
原因:可能用户没有权限
可能防火墙.
--转自