手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表Tag:mysql proxy

MySQL-Proxy的安装配置

本来对于mysql proxy 0.70的release是仅仅当成一个新闻来报道的。结果,老王却写了一篇教你如何配置的文章,你说我是转好呢还是不转好呢?
上午我刚写,人家老王下午就来配置,你说我不转,对得起人家伐?
所以,我只好辛苦一点,,转载一下喽。。

感谢老王

原文:http://hi.baidu.com/thinkinginlamp/blog/item/f96559821fbda8aa0cf4d200.html

MySQL-Proxy二进制版本的安装相对简单,无需多言,下面介绍的是源代码安装:

安装pkg-config

tar zxvf pkg-config-0.23.tar.gz
cd pkg-config-0.23
./configure
make
make install

确保PKG_CONFIG_PATH环境变量包含了相关的pkg-config配置文件路径:

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

安装libevent

tar zxvf libevent-1.4.10-stable.tar.gz
cd libevent-1.4.10-stable
./configure
make
make install

安装glib

tar zxvf glib-2.20.0.tar.gz
cd glib-2.20.0
./configure
make
make install

安装lua

tar zxvf lua-5.1.4.tar.gz
cd lua-5.1.4

如果你的服务器是64位的,这时要调整一下Makefile:vi src/Makefile,在CFLAGS里加上-fPIC,否则会出错:

/usr/bin/ld: /usr/local/lib/liblua.a(lapi.o):
relocation R_X86_64_32 against `luaO_nilobject_' can not be used when making a shared object;
recompile with -fPIC
/usr/local/lib/liblua.a: could not read symbols: Bad value

接下来不用执行常见的configure,直接make:

make linux
make install

安装pkg-config配置文件,以便编译mysql-proxy时能找到lua:

cp etc/lua.pc /usr/local/lib/pkgconfig/lua5.1.pc

如果没有执行此步骤的话,在后面编译安装mysql-proxy的时候,会得到类似下面的错误信息:

Package lua5.1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `lua5.1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua5.1' found

安装mysql

这里介绍的是完整安装mysql,其实你只要安装mysql开发包即可。

tar zxvf mysql-5.1.33.tar.gz
cd tar zxvf mysql-5.1.33
./configure
make
make install
cp support-files/mysql.server /etc/init.d/mysql
chown +x /etc/init.d/mysql
cp support-files/my-[small|medium|large|huge|innodb-heavy-4G].cnf /etc/my.cnf

如果my.cnf里有skip-federated选项,就注释它,否则安装数据库的时候会出现类似下面的错误:
[ERROR] /usr/local/libexec/mysqld: unknown option '--skip-federated'

/usr/local/bin/mysql_install_db --user=mysql
/usr/local/bin/mysqld_safe --user=mysql &

保证系统能找到mysql_config,后面编译mysql-proxy会用到它:

export PATH=$PATH:/usr/local/bin

还要保证系统能找到mysql库文件:

vi /etc/ld.so.conf 加入/usr/local/lib目录

执行:/sbin/ldconfig /etc/ld.so.conf

安装mysql-proxy

tar zxvf mysql-proxy-0.7.0.tar.gz
cd mysql-proxy-0.7.0
./configure
make
make install

按照官方介绍做好启动脚本/etc/init.d/mysql-proxy和参数脚本/etc/sysconfig/mysql-proxy,并设置:

chmod +x /etc/init.d/mysql-proxy
chkconfig --add mysql-proxy

搞定了,测试一下:/usr/local/sbin/mysql-proxy -V。官方论坛里有很多讨论,可以参阅。

Tags: mysql proxy, 老王

MySQL Proxy 0.7.0 is finally released

mysql proxy 终于有一个release版本了。只是我最近还用不到这个。纯记录一下

MySQL Proxy 0.7.0 is finally released:

The full ChangeLog is a bit longer as 0.7.0 was more than a year in the works. To make it short: it is faster, better and more flexible.

Binaries will be release at http://dev.mysql.com/downloads/mysql-proxy/index.html shortly.

For everyone who just wants to update from 0.6.1 to 0.7.0 you should just see a major speed improvement.

  • A bug in the connect()-phase that caused to leave the Naggle-algorithm enabled caused a unneccesary high latency.
  • We also changed the buffering of result-sets to only buffer them if the scripts really ask for them with resultset_is_needed = true, see the examples.

Please keep in mind that 0.7.0 isn't a drop-in replacement for 0.6.1. We changed a few objects inside the lua layer which need some small changes to your Lua scripts:

  • proxy.backends.* is now proxy.global.backends.*
  • proxy.connection.client.address is now proxy.connection.client.src.address full description
  • the resultset is only available in the resultset handler if proxy.queries:append(id, packet, { resultset_is_needed = true })

Our focus for the way to 1.0 will be around threading to remove this scalability bottleneck. A first code-drop is already available at launchpad: threaded-io

Tags: mysql proxy