Centos5.8 Mysql-proxy-0.8.3的安装
1.升级glib,参见tendy的博文:http://tendy.blog.51cto.com/1242864/1189065
2.安装pkg-config
tar zxvf pkg-config-0.28.tar.gz
cd pkg-config-0.28
./configure --prefix=/usr \
--docdir=/usr/share/doc/pkg-config-0.28 \
--with-internal-glib;
make
make install
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
source /etc/profile
cd ..
3.安装libevent
tar zxvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=/usr/local/libevent
make && make install
export LDFLAGS="-L/usr/local/libevent/lib -lm"
export CPPFLAGS="-I/usr/local/libevent/include"
export CFLAGS="-I/usr/local/libevent/include"
source /etc/profile
cd ..
4.安装lua
tar zxvf lua-5.1.5.tar.gz
cd lua-5.1.5
make linux
make install
export LUA_CFLAGS="-I/usr/local/lua/include"
export LUA_LIBS="-L/usr/local/lua/lib/ -llua -ldl"
source /etc/profile
cd ..
5.安装mysql-5.1.68
tar zxvf mysql-5.1.68.tar.gz
cd mysql-5.1.68
./configure --prefix=/usr/local/mysql --with-extra-charsets=gbk,gb2312,utf8,utf8 --without-server && make && make install
echo "export /usr/local/mysql/bin" >> /etc/profile
source /etc/profile
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
ldconfig
cd ..
6.安装mysql-proxy
tar zxvf mysql-proxy-0.8.3.tar.gz
cd mysql-proxy-0.8.3
./configure --prefix=/usr/local/mysql-proxy --with-mysql=/usr/local/mysql --with-lua
make
make install
cd ..
7.验证mysql-proxy安装是否成功,执行如下命令:
[root@mysql-proxy ~]# /usr/local/mysql-proxy/bin/mysql-proxy --version
mysql-proxy 0.8.3
chassis: mysql-proxy 0.8.3
glib2: 2.28.6
libevent: 2.0.21-stable
LUA: Lua 5.1.5
package.path: /usr/local/mysql-proxy/lib/mysql-proxy/lua/?.lua
package.cpath: /usr/local/mysql-proxy/lib/mysql-proxy/lua/?.so
-- modules
proxy: 0.8.3
8.配置mysql-proxy
vi mysql-proxy.cnf
[mysql-proxy]
admin-username = mysqlproxyadm
admin-password = abc123
daemon = true
keepalive = true
pid-file = /usr/local/mysql-proxy/mysql-proxy.pid
log-file = /var/log/mysql-proxy.log
log-level = debug
proxy-backend-address = 192.168.201.176:3306
proxy-read-only-backend-address = 192.168.201.177:3306
proxy-lua-script = /usr/local/mysql-proxy/rw-splitting.lua
admin-lua-script = /usr/local/mysql-proxy/lib/mysql-proxy/lib/mysql-proxy/lua/admin.l
ua
lua-path = /usr/local/mysql-proxy/lib/mysql-proxy/lua/?.lua
lua-cpath = /usr/local/mysql-proxy/lib/mysql-proxy/lua/?.so
9.启动mysql-proxy
/usr/local/mysql-proxy/bin/mysql-proxy --defaults-file=/usr/local/mysql-proxy/etc/mys
ql-proxy.cnf --proxy-fix-bug-25371 &
10.检查mysql-proxy是否运行正常
(1)查看进程
# ps aux|grep mysql-proxy
(2)查看端口是否处于监听状态
# netstat -anl|grep 4040
tcp 0 0 0.0.0.0:4040 0.0.0.0:* LISTEN
# lsof -i:4040
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysql-pro 3271 root 10u IPv4 11199 0t0 TCP *:yo-main (LISTEN)