MySQL代理Atlas在CentOS7.0中的源码安装实践(设置开机自启)

提示:如要去掉SQL过滤(无WHERE子句的UPDATE和DELETE)功能,可以先修改源码

修改文件 Atlas-2.2.1\plugins\proxy\proxy-plugin.c

修改方法 is_in_blacklist,直接返回FALSE

 

依赖包:

glib-2.32.4.tar.xz

glibc-devel  libevent-devel  lua-devel  openssl-devel  flex  mysql-devel xz  gettext-devel

 

分步命令:

# 安装依赖包
yum install -ylibevent-devel libffi-devel lua-devel openssl-devel flex
yum install -y mysql-devel
 
# 源码安装glib
yum install -y xzgettext-devel
tar xvf glib-2.32.4.tar.xz
cd glib-2.32.4
./configure
make
make install
 
# 如果没有编译成功,请尝试以下
yum install -y gcc glibc-develglib2-devel
 
 
# 源码安装Atlas
tar xvfAtlas-2.2.1.tar.gz
cd Atlas-2.2.1
vi ./plugins/proxy/proxy-plugin.c
/ is_in_blacklist  # 在方法体的开始和最后一行前添加 /** */ 注释
:wq
 
./configure --prefix=/usr/local/mysql-proxy CFLAGS="-DHAVE_LUA_H -O2" LDFLAGS="-lm -ldl -lcrypto" LUA_CFLAGS="-I/usr/local/include" LUA_LIBS="-L/usr/local/lib -llua" GLIB_CFLAGS="-I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include/glib-2.0/glib/" GLIB_LIBS="-L/usr/local/lib -lglib-2.0" GMODULE_CFLAGS="-I/usr/local/include" GMODULE_LIBS="-L/usr/local/lib -lgmodule-2.0" GTHREAD_CFLAGS="-I/usr/local/include" GTHREAD_LIBS="-L/usr/local/lib -lgthread-2.0"
make
make install
 
# 为Atlas打包绿色安装文件
cd /usr/local
tar -zcvf/tmp/Atlas-2.2.1.el7.x86_64-modify.tar.gz mysql-proxy/* --exclude log/*


将atlas设置成服务,并实现开机自动启动

说明:作者仅在CentOS7.0上进行了测试,而且没有进行可靠性和稳定性的测试!

cp /tmp/atlas /etc/rc.d/init.d/atlas
chmod +x /etc/rc.d/init.d/atlas
chkconfig --add atlas
chkconfig atlas on


/tmp/atlas文件的内容如下:

#!/bin/sh
#Author:HuangfuFanFeng <[email protected]>
#chkconfig: 2345 80 90
#description: atlas autorun
#your instance name
instance_name=test
case "$1" in 
    "start")
        /usr/local/mysql-proxy/bin/mysql-proxyd $instance_name start
        ;; 
    "stop") 
        /usr/local/mysql-proxy/bin/mysql-proxyd $instance_name stop
       ;; 
    "restart") 
        /usr/local/mysql-proxy/bin/mysql-proxyd $instance_name restart
      ;; 
    "status") 
        /usr/local/mysql-proxy/bin/mysql-proxyd $instance_name status
       ;; 
    *) 
  echo "Usage: service atlas start/stop/restart/status "                              
       ;; 
  esac

使用命令如下:

service atlas start
service atlas stop
service atlas status
service atlas restart


你可能感兴趣的:(mysql,centos,mysql-proxy,Atlas)