Mysql-proxy安装配置
作者:lixiuran 日期:2014年5月2日
相关软件包以后提供!
一、安装前准备
1.mysql-proxy安装前所需依赖包
libevent 1.x or higher (1.3b or later is preferred) lua 5.1.x or higher(使用5.2版本编译时会出现大量错误) glib2 2.6.0 or higher pkg-config
libtool 1.5 or higher
MySQL 5.0.x or higher developer files gettext 0.18.2
2.获取依赖包及mysql-proxy:
1.libevent-2.0.21:https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
2.lua-5.1.5:http://www.lua.org/ftp/lua-5.1.5.tar.gz
3.glib-2.34.3:http://ftp.gnome.org/pub/gnome/sources/glib/2.34/glib-2.34.3.tar.xz
4.gettext-0.18.2:http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.2.tar.gz 5.mysql-5.6:http://dev.mysql.com/downloads/mysql/
6.mysql-proxy-0.8.3:http://dev.mysql.com/downloads/mysql-proxy/ 3.安装前配置环境
1.操作系统:centOS6.4 x86_64 2.执行yum install zlib* libffi* gcc gcc-c++ make autoconf automake libtool pkgconfig lrzsz xz ncurses* readline cmake
二、安装部署依赖包 1.安装libevent
#tar -zxvf libevent-2.0.21-stable.tar.gz #cd libevent-2.0.21-stable #./configure #make
#make install
2.安装lua
#tar -zxvf lua-5.1.5.tar.gz #cd lua-5.1.5
#vi src/Makefile(64位系统必须修改) CFLAGS= -O2 -Wall $(MYCFLAGS) 添加-fPIC
CFLAGS= -fPIC -O2 -Wall $(MYCFLAGS) #make linux
#make install INSTALL_TOP=/usr/local/lua #cp etc/lua.pc /usr/local/lib/pkgconfig/ 3.安装glib
安装前检查是否有命令:msgfmt
如果没有先安装gettext
#tar -zxvf gettext-0.18.2.tar.gz #cd gettext-0.18.2
#./configure --prefix=/usr/local/gettext #make && make install
#ln -s /usr/local/gettext/bin/* /usr/local/bin/
安装glib
#tar -Jxvf glib-2.34.3.tar.xz #cd glib-2.34.3
#./configure --prefix=/usr/local/glib #make
#make install
4.安装mysql(也可使用开发者库替代)
#groupadd -g 101 mysql
#useradd -u 501 -s /sbin/nologin -g mysql mysql #mkdir -p /home/db_mysql/data
#chown -R mysql.mysql /home/db_mysql/data #tar -zxvf mysql-5.6.11.tar.gz #cd mysql-5.6.11 #cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/home/db_mysql/data/mysql.sock \ -DMYSQL_DATADIR=/home/db_mysql/data \ -DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \ -DENABLED_LOCAL_INFILE=on \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 #make && make install
三、安装mysql-proxy
#export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
#export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/glib/lib/pkgconfig #export LUA_CFLAGS="-I/usr/local/lua/include" #export LUA_LIBS="-L/usr/local/lua/lib -llua -ldl" #export LDFLAGS="-L/usr/local/lib -lm" #export CFLAGS="-I/usr/local/lib" #tar -zxvf mysql-proxy-0.8.3.tar.gz #cd mysql-proxy
#./configure --prefix=/usr/local/mysql-proxy --with-lua=/usr/local/lua --with-mysql=/usr/local/mysql #make
#make install
#mkdir /usr/local/mysql-proxy/conf
#cp ./lib/*.lua /usr/local/mysql-proxy/conf
测试启动
#./mysql-proxy --proxy-backend-addresses=192.168.157.130:3306 --proxy-read-only-backend-addresses=192.168.157.130:3307
--proxy-lua-script=/usr/local/mysql-proxy/conf/rw-splitting.lua 提示
2013-07-03 02:39:58: (critical) plugin proxy 0.8.3 started 启动成功
在客户端使用mysql -h 192.168.157.135 -P 4040(mysql-proxy的IP及监听端口号) 若能登陆mysql则代理成功