yum -y install gcc gcc-c++ autoconf mysql-devel libtool pkgconfig ncurses ncurses-devel
wget http://monkey.org/~provos/libevent-2.0.13-stable.tar.gz
tar zxvf libevent-2.0.13-stable.tar.gz
cd libevent-2.0.13-stable
./configure
make
make install
wget http://ftp.gnome.org/pub/gnome/sources/glib/2.18/glib-2.18.4.tar.gz
tar xvf glib-2.18.4.tar.gz
cd glib-2.18.4
./configure
make
make install
###lua安装5.1.4版本,安装之前需要先安装readline 6.1,不然会报错缺少头文件
wget ftp://ftp.cwru.edu/pub/bash/readline-6.1.tar.gz
tar zxvf readline-6.1.tar.gz
cd readline-6.1
./configure
make
make install
ldconfig –v
wget http://www.lua.org/ftp/lua-5.1.4.tar.gz
tar xvf lua-5.1.4.tar.gz
cd lua-5.1.4
vi src/Makefile
CFLAGS= -O2 -Wall -fPIC $(MYCFLAGS) # 64位系统时,需在CFLAGS里加上-fPIC
make linux
make install
###pkg-config 环境变量
cp etc/lua.pc /usr/local/lib/pkgconfig/
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
###Mysql-proxy#####
wget http://mirrors.ukfast.co.uk/sites/ftp.mysql.com/Downloads/MySQL-Proxy/mysql-proxy-0.8.2-linux-glibc2.3-x86-32bit.tar.gz
tar zxvf mysql-proxy-0.8.2-linux-glibc2.3-x86-32bit.tar.gz
cp -R mysql-proxy-0.8.2-linux-glibc2.3-x86-32bit /usr/local/mysql-proxy/
cp /usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua /usr/local/lib/
cp /usr/local/mysql-proxy/share/doc/mysql-proxy/admin.lua /usr/local/lib/
##默认最小4个最大8个以上的客户端连接才会实现读写分离, 现改为最小1个最大2个:
# vi +40 /usr/local/lib/rw-splitting.lua
------------------------------------------------------
-- connection pool
if not proxy.global.config.rwsplit then
proxy.global.config.rwsplit = {
min_idle_connections = 1,
max_idle_connections = 2,
is_debug = false ###调试
}
end
环境变量
export PATH=$PATH:/usr/local/mysql/mysql-proxy/sbin/
/usr/local/mysql-proxy/bin/mysql-proxy --proxy-backend-addresses=192.168.1.21:3306 --proxy-read-only-backend-addresses=192.168.1.90:3306 --proxy-lua-script=/usr/local/lib/rw-splitting.lua &
#如果有多个Slave的话, proxy-read-only-backend-addresses参数可以配置多个以逗号分隔的IP:Port从库列表.