码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2015-01-14 01:02:42      阅读:321      评论:0      收藏:0      [点我收藏+]

标签:atlas mysql mysql-proxy centos

提示:如要去掉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 <fan.hf@sina.com>
#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


本文出自 “◆峰回路转◇2015启程◆” 博客,请务必保留此出处http://huangfuff.blog.51cto.com/2632203/1603692

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

标签:atlas mysql mysql-proxy centos

原文地址:http://huangfuff.blog.51cto.com/2632203/1603692

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!