本文主要介绍中间件atlas源码编译安装,由于rpm安装的atlas程序调用时返回的mysql版本为5.0,相应使用低版本的驱动造成时间类型的字段无法支持毫秒级别。
由于需要glib版本要大于2.32以上,centos6系统自带的glib版本为2.28,因此需要重新编译安装2.32以上的glib,这里安装2.34版本的glib需要依赖pcre大于8.31。
一、编译安装pcre8.35
# tar xf pcre-8.35.tar.gz
# cd pcre-8.35
# ./configure --prefix=/usr/local/glib--with-pcre=/usr/local/pcre/
二、编译安装glib-2.34.3.tar.xz
# tar xf glib-2.34.3.tar.xz
# cd glib-2.34.3
#./configure --prefix=/usr/local/glib --with-pcre=/usr/local/pcre/
三、编译安装Atlas-2.2.1.tar.gz
1.解决依赖关系
# yum install libffi-devel lua-devel libeventlibevent-devel
2.修改源码中mysql版本代码,这里mysql版本为5.6.17
找到plugins/proxy/proxy-plugin.c文件
修改1974行:challenge->server_version_str =g_strdup("5.0.81-log");
为:challenge->server_version_str= g_strdup("5.6.17-log");
修改1974行:challenge->server_version = 50081;
为challenge->server_version= 50617;
3.安装atlas
# tar xf Atlas-2.2.1.tar.gz
# cd Atlas-2.2.1
# exportPKG_CONFIG_PATH=/usr/local/glib/lib/pkgconfig
# ./configure --with-mysql=/usr/local/mysql5.6/bin/mysql_config--prefix=/usr/local/mysql-proxy LDFLAGS="-lcrypto"
# make && make install
或者修改bootstrap.sh
#!/bin/sh
base=$(cd "$(dirname "$0")"; pwd)
cd $base
PKG_CONFIG_PATH=/usr/local/glib/lib/pkgconfig ./configure --with-mysql=/usr/local/mysql/bin/mysql_config --prefix=/usr/local/mysql-proxy CPPFLAGS="-I/usr/local/mysql/include/" LDFLAGS="-L/usr/local/mysql/lib/ -lm -ldl -lcrypto" LUA_CFLAGS="-I/usr/include/" LUA_LIBS="-L/usr/lib64 -llua"
执行
# ./bootstrap.sh
# make && make install
注意:以上相关程序的头文件和库文件根据自己的环境修改相应的路径
四、启动atlas
# /usr/local/mysql-proxy/bin/mysql-proxyd test start
报错
2016-08-0518:05:26: (critical) loading module '/usr/local/mysql-proxy/lib/mysql-proxy/plugins/libproxy.so'failed: libmy
sqlclient.so.18:cannot open shared object file: No such file or directory
2016-08-0518:05:26: (critical) setting --plugin-dir=<dir> might help
2016-08-0518:05:26: (message) Initiating shutdown, requested from mysql-proxy-cli.c:441
2016-08-0518:05:26: (message) shutting down normally, exit code is: 1
解决,导入mysql的库文件到系统
# echo '/usr/local/mysql/lib/' >> /etc/ld.so.conf
# ldconfig
五、atlas升级替换
1.确保待升级的atlas主机操作系统与编译软件的操作系统版本一致
连同编译安装的glib一并部署,同时需要安装依赖关系libffi-devel lua-devel libevent libevent-devel
来源:oschina
链接:https://my.oschina.net/u/4316091/blog/4317256