Mysql Atlas 安装记录

Atlas是360团队弄出来的一套基于MySQL-Proxy基础之上的代理,修改了MySQL-Proxy的一些BUG,并且优化了很多东西。
Atlas官方链接: https://github.com/Qihoo360/Atlas/blob/master/README_ZH.md
Atlas下载链接: https://github.com/Qihoo360/Atlas/releases

依赖包安装
****************************************************************************************

lua安装
-------------------------------------------
yum install -y libtermcap-devel ncurses-devel libevent-devel readline-devel
tar -zxvf lua-5.1.5.tar.gz
chown -R root.root *
cd lua-5.1.5/

修改当前目录下的“Makefile”中的 INSTALL_TOP= /usr/local为 INSTALL_TOP= /usr/local/lua
主要是为了避免与系统自带的lua库发生冲突的可能
vim Makefile
INSTALL_TOP= /usr/local/lua
make linux install

glib-2.49安装
----------------------------------------
rpm -q ncurses readline readline-devel lua libffi libffi-devel libiconv xz glib2 cmake popt libnl libevent libevent-devel openssl-devel libtermcap-devel ncurses-devel
yum install -y libffi-devel libtermcap-devel
http://www.rpmfind.net/linux/rpm2html/search.php?query=libevent-devel
rpm -ivh libevent-devel-2.0.21-4.el7.x86_64.rpm

libiconv依赖包
tar xvzf libiconv-1.14.tar.gz
chown -R root.root *
cd libiconv-1.14
cd srclib
sed -i -e ‘/gets is a security/d‘ ./stdio.in.h
cd ..
注意不要建立独立目录,一定要安装在/usr/local目录下,不然安装glib时会报/usr/bin/ld: cannot find -liconv
./configure --prefix=/usr/local gl_cv_header_working_stdint_h=yes
make
make install

pkg安装
tar -zxvf pkg-config-0.29.2.tar.gz
chown -R root.root *
cd pkg-config-0.29.2/
./configure --enable-iconv=no --with-libiconv=gnu --with-internal-glib
make
make install

ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2
ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/libiconv.so.2
pkg-config --version
0.29.2

pcre安装
tar -zxvf pcre-8.39.tar.gz
chown -R root.root *
cd pcre-8.39/
./configure --enable-utf8 --enable-unicode-properties
make
make install
ln -s /usr/local/lib/libpcre.so.1 /lib
ln -s /usr/local/lib/libpcreposix.so.0 /lib

glib安装
rpm -q libffi-devel
xz -d glib-2.49.7.tar.xz
chown -R root.root *
tar -xvf glib-2.49.7.tar

mkdir /usr/local/glib-2.49.7
cd glib-2.49.7/
./configure --prefix=/usr/local/glib-2.49.7 --with-libiconv=gnu LIBFFI_CFLAGS="-I/usr/local/include" LIBFFI_LIBS="-L/usr/local/lib -lffi"
make
make install

配置PKG-CONFIG
# find /usr/ -name pkgconfig
/usr/lib64/pkgconfig
/usr/share/pkgconfig
/usr/local/lib/pkgconfig
/usr/local/lib64/pkgconfig
/usr/local/mysql/lib/pkgconfig
/usr/local/glib-2.49.7/lib/pkgconfig

# cd /usr/local/glib-2.49.7/lib/pkgconfig
# ls
gio-2.0.pc gio-unix-2.0.pc glib-2.0.pc gmodule-2.0.pc gmodule-export-2.0.pc gmodule-no-export-2.0.pc gobject-2.0.pc gthread-2.0.pc

vim .bash_profile
export PKG_CONFIG_PATH=/usr/local/glib-2.49.7/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/mysql/lib/pkgconfig:$PKG_CONFIG_PATH
. ./.bash_profile

测试glib pkg
vim hello.c
#include <stdio.h>
#include <glib.h>
int main(int argc, char** argv){
GList* list=NULL;
list=g_list_append(list,"Hello world!");
list=g_list_append(list,"made by pcat");
list=g_list_append(list,"http://www.cnblogs.com/perfei/");
printf("The first item is %s\n",g_list_first(list)->data);
return 0;
}

编译如下:
gcc hello.c -o hello $(pkg-config --cflags --libs glib-2.0)

# ls -ltr | grep hello
-rw-r--r-- 1 root root 305 11月 20 16:47 hello.c
-rwxr-xr-x 1 root root 8648 11月 20 17:05 hello

# ./hello
The first item is Hello world!

Atlas数据库中间件安装配置
****************************************************************************************

安装
--------------------------------------------------------------------------------------------
tar -zxvf Atlas-2.2.1.tar.gz
chown -R root.root *
cd Atlas-2.2.1/
mkdir /usr/local/mysql-proxy
./configure --prefix=/usr/local/mysql-proxy \
--with-lua=/usr/local/lua \
--with-mysql=/usr/local/mysql \
GLIB_CFLAGS="-I/usr/local/glib-2.49.7/include/glib-2.0" \
GLIB_LIBS="-L/usr/local/glib-2.49.7/lib/ -lglib-2.0" \
GMODULE_CFLAGS="-I/usr/local/glib-2.49.7/include" \
GMODULE_LIBS="-L/usr/local/glib-2.49.7/lib -lgmodule-2.0" \
GTHREAD_CFLAGS="-I/usr/local/glib-2.49.7/include" \
GTHREAD_LIBS="-L/usr/local/glib-2.49.7/lib -lgthread-2.0" \
LUA_CFLAGS="-I/usr/local/lua/include" \
LUA_LIBS="-L/usr/local/lua/lib -llua-5.1" \
CFLAGS="-DHAVE_LUA_H -O2" \
LDFLAGS="-L/usr/local/lib -L/usr/local/lib64 -lm -ldl -lcrypto"

Atlas2.2.1 对应的是 mysql5.6 的版本,使用mysql5.7时需要进行以下调整
共四处需要替换,详见错误信息
vim src/network-mysqld-packet.c
:%s/CLIENT_SECURE_CONNECTION/CLIENT_RESERVED2/g
共一处需要替换,详见错误信息
vim ./plugins/admin/admin-plugin.c
:%s/CLIENT_SECURE_CONNECTION/CLIENT_RESERVED2/g

make
make如果报错处理,可进行以下处理
ln -s /usr/local/glib-2.49.7/lib/glib-2.0/include/glibconfig.h /usr/local/glib-2.49.7/include/glib-2.0

make install
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/mysql-proxy/lib/mysql-proxy/plugins

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR‘
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH‘ environment variableduring execution
- add LIBDIR to the `LD_RUN_PATH‘ environment variableduring linking
- use the `-Wl,-rpath -Wl,LIBDIR‘ linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf‘

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

cd /usr/local
mv mysql-proxy atlas-2.2.1 && ln -s atlas-2.2.1 mysql-proxy

配置文件
--------------------------------------------------------------------------------------------
/usr/local/mysql-proxy/bin/encrypt Admin_123
ywy55weCQG6TZ6zxvGQr9A==
/usr/local/mysql-proxy/bin/encrypt rootroot
MdUKAaW7vcwa8s/oWZlMvQ==

vim /usr/local/mysql-proxy/conf/atlas.cnf
[mysql-proxy]
admin-username = atlasadmin
admin-password = Admin_123

proxy-backend-addresses = 10.168.21.186:3306
proxy-read-only-backend-addresses = 10.168.21.186:[email protected],10.168.21.187:[email protected],10.168.21.188:[email protected]

pwds = admin:ywy55weCQG6TZ6zxvGQr9A==,root:MdUKAaW7vcwa8s/oWZlMvQ==

daemon = true
keepalive = true
event-threads = 16

log-level = message
log-path = /usr/local/mysql-proxy/log
sql-log = ON

proxy-address = 0.0.0.0:3309
admin-address = 0.0.0.0:3307

charset = utf8

启动
--------------------------------------------------------------------------------------------
/usr/local/mysql-proxy/bin/mysql-proxyd atlas start
OK: MySQL-Proxy of atlas is started

# ps -ef | grep atlas
root 26516 1 0 14:42 ? 00:00:00 /usr/local/mysql-proxy/bin/mysql-proxy --defaults-file=/usr/local/mysql-proxy/conf/atlas.cnf
root 26517 26516 0 14:42 ? 00:00:00 /usr/local/mysql-proxy/bin/mysql-proxy --defaults-file=/usr/local/mysql-proxy/conf/atlas.cnf

启动脚本
# vim /etc/init.d/atlas

#!/bin/sh
#
# mysql-proxy This script starts and stops the mysql-proxy daemon
#
# chkconfig: - 78 30
# processname: mysql-proxy
# description: mysql-proxy is a proxy daemon to mysql
# config: /usr/local/mysql-proxy/conf/mysql-proxy.cnf
# pidfile: /usr/local/mysql-proxy/log/mysql-proxy.pid
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

DAEMON="/usr/local/mysql-proxy/bin/mysql-proxy"
CONFIGFILE="/usr/local/mysql-proxy/conf/atlas.cnf"
PIDFILE="/usr/local/mysql-proxy/log/mysql-proxy.pid"
LOCKFILE="/var/lock/subsys/mysql-proxy"
PROG=`basename $DAEMON`

RETVAL=0

start() {
echo -n $"Starting ${PROG}......"
[ -x $DAEMON ] || exit 5
[ -f $CONFIGFILE ] || exit 6
${DAEMON} --defaults-file=${CONFIGFILE} || echo -n "${PROG} already running"

RETVAL=$?
echo
[[ $RETVAL -eq 0 ]] && touch $LOCKFILE

return $RETVAL
}

stop() {
echo -n $"Stopping ${PROG}......"
if [[ `ps aux | grep bin/mysql-proxy | grep -v grep | wc -l` -gt 0 ]]; then
kill -TERM `ps -A -oppid,pid,cmd | grep bin/mysql-proxy | grep -v grep | awk ‘{print $2}‘`
fi

RETVAL=$?
echo
[[ $RETVAL -eq 0 ]] && rm -f $LOCKFILE $PIDFILE

return $RETVAL
}

restart() {
stop
sleep 1
start
}

case "$1" in
start)
start
;;

stop)
stop
;;

restart)
restart
;;

condrestart)
[[ -e $LOCKFILE ]] && restart
;;

*)
echo "Usage: $0 {start|stop|restart|condrestart}"
RETVAL=1
;;
esac

exit $RETVAL

chmod +x /etc/init.d/atlas
chmod 0660 /usr/local/mysql-proxy/conf/atlas.cnf
service atlas stop
service atlas start

# service atlas stop
Stopping mysql-proxy......
# service atlas start
Unit atlas.service could not be found.
Starting mysql-proxy......

# /etc/init.d/atlas stop
Stopping mysql-proxy......
# /etc/init.d/atlas start
Starting mysql-proxy......

# ps -ef | grep atlas
root 27560 1 0 14:49 ? 00:00:00 /usr/local/mysql-proxy/bin/mysql-proxy --defaults-file=/usr/local/mysql-proxy/conf/atlas.cnf
root 27561 27560 0 14:49 ? 00:00:00 /usr/local/mysql-proxy/bin/mysql-proxy --defaults-file=/usr/local/mysql-proxy/conf/atlas.cnf
root 27591 15666 0 14:49 pts/1 00:00:00 grep --color=auto atlas

连接
------------------------------------------------------------------

管理接口登录,即DBA数据库管理使用的接口
# mysql -h127.0.0.1 -P3307 -uatlasadmin -pAdmin_123
[[email protected] oms]$ mysql -h10.168.21.187 -P3307 -uatlasadmin -pAdmin_123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.99-agent-admin

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql> select * from help;
+-------------------------------+---------------------------------------------------------+
| command | description |
+-------------------------------+---------------------------------------------------------+
| SELECT * FROM help | shows this help |
| SELECT * FROM backends | lists the backends and their state |
| SET OFFLINE $backend_id | offline backend server, $backend_id is backend_ndx‘s id |
| SET ONLINE $backend_id | online backend server, ... |
| ADD MASTER $backend | example: "add master 127.0.0.1:3306", ... |
| ADD SLAVE $backend | example: "add slave 127.0.0.1:3306", ... |
| REMOVE BACKEND $backend_id | example: "remove backend 1", ... |
| SELECT * FROM clients | lists the clients |
| ADD CLIENT $client | example: "add client 192.168.1.2", ... |
| REMOVE CLIENT $client | example: "remove client 192.168.1.2", ... |
| SELECT * FROM pwds | lists the pwds |
| ADD PWD $pwd | example: "add pwd user:raw_password", ... |
| ADD ENPWD $pwd | example: "add enpwd user:encrypted_password", ... |
| REMOVE PWD $pwd | example: "remove pwd user", ... |
| SAVE CONFIG | save the backends to config file |
| SELECT VERSION | display the version of Atlas |
+----------------------------+---------------------------------------------------------+
16 rows in set (0.00 sec)

工作接口,即应用访问的接口
# mysql -h10.168.21.187 -P3309 -uadmin -pAdmin_123

[[email protected] oms]$ mysql -h10.168.21.187 -P3309 -uadmin -pAdmin_123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.81-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.17 sec)

时间: 2024-07-30 19:59:04

Mysql Atlas 安装记录的相关文章

菜鸟的《Linux程序设计》学习(8):MySQL数据库安装、配置及基本操作

1. MySQL数据库: 在涉及到一些大型的Web系统或者嵌入式软件的开发时,都少不了用数据库来管理数据.在Windows操作系统下,使用过各种各样的数据库,如:sqlServer.Oracle.MySQL等等,我们知道,在Windows系统上的软件安装配置都是界面式,操作明显而简捷. 那么在Linux操作系统上,对于数据库的选用,好像首推的是MySQL,它是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司.MySQL是一种关联数据库管理系统,关联数据库将数据保

CentOS上Mysql安装记录

转java了,所以服务端也折腾一下linux. 下面的内容都比较新手,勿喷,见谅. CentOS的安装. 安装界面上有一个网络设置,务必选择可连接,否则进入系统后无网络,稍微有点麻烦,因为我的 Hyper 虚拟机是dhcp的,ip地址也比较难记,所以设置起来比较手足无措. Mysql 安装 然后就是安装 Mysql,现在yum的仓库里已经没有mysql了 (谁让它被开源大敌oracle收购了呢..),所以需要先手动添加一个. 直接将rpm文件下载下来: wget https://dev.mysq

Windows系统zip安装MySQL 5.7记录

1下载zip安装包,https://dev.mysql.com/downloads/mysql/ 2.解压安装包到安装的目标路径,(例:D:\Server\MySQL57) 3.新建MySQL配置文件my.ini,配置安装路径,新建文件夹data存放MySQL数据,配置存放目录 配置内容如下: [client] default-character-set=utf8mb4 [mysql] # 设置mysql客户端默认字符集 default-character-set=utf8mb4 [mysqld

Atlas 安装和配置

Atlas是由 Qihoo 360,  Web平台部基础架构团队开发维护的一个基于MySQL协议的数据中间层项目.它在MySQL官方推出的MySQL-Proxy 0.8.2版本的基础上,修改了大量bug,添加了很多功能特性.目前该项目在360公司内部得到了广泛应用,很多MySQL业务已经接入了Atlas平 台,每天承载的读写请求数达几十亿条. 主要功能:* 读写分离* 从库负载均衡* IP过滤* SQL语句黑白名单* 自动分表 一.环境OS :CentOS-6.4 x86_64Atlas IP

MySQL —— Atlas 使用

配置: Centos 6.6 minimal CPU:    E5 - 2620 x 2 Mem:   64G Disk :   1T 内核配置如下: [[email protected] ~]# sysctl -p net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_p

Python 3 mysql 简介安装

Python 3 mysql 简介安装 一.数据库是什么 1.  什么是数据库(DataBase,简称DB) 数据库(database,DB)是指长期存储在计算机内的,有组织,可共享的数据的集合.数据库中的数据按一定的数字模型组织.描述和存储,具有较小的冗余,较高的数据独立性和易扩展性,并且可为各种用户共享. 2.什么是数据(Data) 描述事物的符号记录称为数据,描述事物的符号既可以是数字,也可以是文字.图片,图像.声音.语言等,数据由多种表现形式,它们都可以经过数字化后存入计算机 在计算机中

MySQL平台安装及应用

       Mysql数据库安装应用 1:MySQL是一个多用户,多线程的服务. 优点: 高性能 高可靠,易于使用 默认使用TCP 的3306端口匹配文件为 /etc/my.cnf   2:MySQL的编译安装过程: 使用rpm -q mysql-server  mysql 检查是否安装MySQL数据包,如果有建议卸载,否则后续发生冲突 安装ncurses-devel包解决依赖关系 rpm -ivh /media/Packages/ncurses-devel-5.7-3.20090208.e1

Centos 7下mysql的安装与配置

将mysql的安装文件放入虚拟机,ftp软件上传上去 配置yum,用yum进行安装mysql 进行mysql的重置:mysql_install_db --datadir=/var/lib/mysql 进入/var/lib/mysql修改权限 chown mysql:mysql * -R 进入root目录,查看.mysql_secret中所记录的密码:cat .mysql_secret 用上面的密码登陆进数据库    mysql -u root -p 更改密码   alter user 'root

Mysql linux 安装文档

1.安装依赖包 yum -y install gcc-c++ ncurses-devel cmake make perl gcc autoconf automake zlib libxml libgcrypt libtool bison 2.安装boost库: 首先先查询是否已经安装过boost rpm -qa boost* 卸载旧boost-*等库: yum -y remove boost-* 下载Boost库,在解压后复制到/usr/local/boost目录下,然后重新cmake并在后面的