3、MySQL-Proxy的读写分离主要是通过rw-splitting.lua脚本实现的,因此需要安装lua。
这里我们建议采用源码包进行安装
wget http://www.lua.org/ftp/lua-5.1.4.tar.gz
tar zvfx lua-5.1.4.tar.gz
cd lua-5.1.4
vi src/Makefile
在 CFLAGS= -O2 -Wall $(MYCFLAGS) 这一行记录里加上-fPIC,更改为 CFLAGS= -O2 -Wall -fPIC $(MYCFLAGS) 来避免编译过程中出现错误。
Yum install readline* #编译lua的时候需要
make linux
make install
[root@cnblackhat ~]# useradd -r mysql-proxy
[root@cnblackhat ~]# tar xf mysql-proxy-0.8.3-linux-glibc2.3-x86-64bit.tar.gz -C /usr/local
[root@cnblackhat ~]# cd /usr/local
[root@cnblackhat local]# ls
bin include libexec mysql share
etc lib lua-5.1.4 mysql-proxy-0.8.3-linux-glibc2.3-x86-64bit src
games lib64 man sbin
在从服务器上测试
[root@jiangsu mysql]# mysql -uroot -p -h192.168.3.137 --port=4040
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 210
Server version: 5.6.22-log Source distribution
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
测试:
在从服务器上用admin登录
[root@jiangsu mysql]# mysql -uadmin -h192.168.3.137 --port=4041 -padmin
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.99-agent-admin
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.