Atlas读写分离[高可用]
Atlas下载地址: https://github.com/Qihoo360/Atlas/releases
Atlas是出于360的, 比mysql-proxy更稳定, 部署起来更方便。
环境:
proxy:192.168.99.60
master:192.168.99.61
slave:192.168.99.62
1.安装
由于我使用的是rpm包, 直接安装
rpm -ivh Atlas-2.2.el6.x86_64.rpm
就是这么简单, 安装完成。
目录默认在:
/usr/local/mysql-proxy
一览目录结构:
total 16
drwxr-xr-x. 2 root root 4096 Dec 12 10:04 bin
drwxr-xr-x. 2 root root 4096 Dec 12 11:04 conf
drwxr-xr-x. 3 root root 4096 Dec 12 10:04 lib
drwxr-xr-x. 2 root root 4096 Dec 12 11:17 log
2.配置文件
cd /usr/local/mysql-proxy/conf vim test.cnf
很多中文指示, 完美
[mysql-proxy] #带#号的为非必需的配置项目 #管理接口的用户名
admin-username = admin #管理接口的密码
admin-password = admin #Atlas后端连接的MySQL主库的IP和端口,可设置多项,用逗号分隔
proxy-backend-addresses = 192.168.99.61:3306 #Atlas后端连接的MySQL从库的IP和端口,@后面的数字代表权重,用来作负载均衡,若省略则默认为1,可设置多项,用逗号分隔
proxy-read-only-backend-addresses = 192.168.99.62:3306@1 #用户名与其对应的加密过的MySQL密码,密码使用PREFIX/bin目录下的加密程序encrypt加密,下行的user1和user2为示例,将其替换为你的MySQL的用户名和加密密码!
pwds = admin:la1Ux+Bu4zo= #设置Atlas的运行方式,设为true时为守护进程方式,设为false时为前台方式,一般开发调试时设为false,线上运行时设为true,true后面不能有空格。
daemon = true #设置Atlas的运行方式,设为true时Atlas会启动两个进程,一个为monitor,一个为worker,monitor在worker意外退出后会自动将其重启,设为false时只有worker,没有monitor,一般开发调试时设为false,线上运行时设为true,true后面不能有空格。
keepalive = true #工作线程数,对Atlas的性能有很大影响,可根据情况适当设置
event-threads = 8 #日志级别,分为message、warning、critical、error、debug五个级别
log-level = message #日志存放的路径
log-path = /usr/local/mysql-proxy/log #SQL日志的开关,可设置为OFF、ON、REALTIME,OFF代表不记录SQL日志,ON代表记录SQL日志,REALTIME代表记录SQL日志且实时写入磁盘,默认为OFF
sql-log = REALTIME #慢日志输出设置。当设置了该参数时,则日志只输出执行时间超过sql-log-slow(单位:ms)的日志记录。不设置该参数则输出全部日志。
#sql-log-slow = 10 #实例名称,用于同一台机器上多个Atlas实例间的区分
instance = test #Atlas监听的工作接口IP和端口
proxy-address = 0.0.0.0:1234 #Atlas监听的管理接口IP和端口
admin-address = 0.0.0.0:2345 #分表设置,此例中person为库名,mt为表名,id为分表字段,3为子表数量,可设置多项,以逗号分隔,若不分表则不需要设置该项
#tables = person.mt.id.3 #默认字符集,设置该项后客户端不再需要执行SET NAMES语句
#charset = utf8 #允许连接Atlas的客户端的IP,可以是精确IP,也可以是IP段,以逗号分隔,若不设置该项则允许所有IP连接,否则只允许列表中的IP连接
#client-ips = 127.0.0.1, 192.168.1 #Atlas前面挂接的LVS的物理网卡的IP(注意不是虚IP),若有LVS且设置了client-ips则此项必须设置,否则可以不设置
#lvs-ips = 192.168.1.1
3.启动
cd /usr/local/mysql-proxy/bin ./mysql-proxyd test start
在这个目录下有mysql-proxy mysql-proxyd, 第一个是mysql团队的, 第二个是属于360团队的, 我们使用的是360的。
端口
netstat -tlnp | grep mysql-proxy tcp 0 0 0.0.0.0:1234 0.0.0.0:* LISTEN 7270/mysql-proxy
tcp 0 0 0.0.0.0:2345 0.0.0.0:* LISTEN 7270/mysql-proxy
留意您的配置文件: 1234端口是api接口, 提供能外部进行工作连接的, 2345是属于内部管理的, 比如查询负载主机状态等。
进程
ps aux | grep mysql-proxy root 1227 0.0 0.0 103244 856 pts/5 S+ 16:03 0:00 grep mysql-proxy
root 7269 0.0 0.0 64916 5168 ? S 11:17 0:00 /usr/local/mysql-proxy/bin/mysql-proxy --defaults-file=/usr/local/mysql-proxy/conf/test.cnf
root 7270 0.5 0.0 196084 40848 ? Sl 11:17 1:30 /usr/local/mysql-proxy/bin/mysql-proxy --defaults-file=/usr/local/mysql-proxy/conf/test.cnf
4.测试
登录内部
mysql -u admin -padmin -P 2345 -h 192.168.99.60 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, 2012, 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 backends; +-------------+--------------------+-------+------+
| backend_ndx | address | state | type |
+-------------+--------------------+-------+------+
| 1 | 192.168.99.61:3306 | up | rw |
| 2 | 192.168.99.62:3306 | up | ro |
+-------------+--------------------+-------+------+
2 rows in set (0.00 sec)
登录外部
mysql -u admin -padmin -P 1234 -h 192.168.99.60 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, 2012, 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>
登录成功, 查看数据库
mysql> show databases; +--------------------+
| Database |
+--------------------+
| information_schema |
| cm_prd |
| jkapp |
| monitorsys |
| mysql |
| mysqlslap |
| ndbinfo |
| performance_schema |
| sso |
| test |
| zskdb |
+--------------------+
11 rows in set (0.01 sec)
查询日志
/usr/local/mysql-proxy/log ls sql_test.log test.log test.pid
sql_test.log是运行过的sql记录, test.log是日志,test.pid是进程ID
cat test.log 2017-12-12 11:17:59: (message) chassis-unix-daemon.c:138: [angel] we try to keep PID=7270 alive
2017-12-12 11:17:59: (message) mysql-proxy 0.8.2 started - instance: test
2017-12-12 11:17:59: (message) proxy listening on port 0.0.0.0:1234
2017-12-12 11:17:59: (message) added read/write backend: 192.168.75.61:3306
2017-12-12 11:17:59: (message) added read-only backend: 192.168.75.62:3306
2017-12-12 11:17:59: (message) chassis-event-thread.c:235: starting 8 threads
cat sql_test.log [12/12/2017 16:17:33] C:192.168.99.60:52091 S:192.168.99.62:3306 OK 6.271 "select @@version_comment limit 1"
[12/12/2017 16:17:37] C:192.168.99.60:52091 S:192.168.99.62:3306 OK 2.425 "show databases"
Atlas读写分离[高可用]的更多相关文章
- MHA+ProxySQL实现读写分离高可用
最近在研究ProxySQL,觉得还挺不错的,所以就简单的折腾了一下,ProxySQL目前也是Percona在推荐的一个读写分离的中间件.关于详细的介绍可以参考官方文档.https://github.c ...
- MySQL for OPS 09:MHA + Atlas 实现读写分离高可用
写在前面的话 前面做了 MHA 高可用,但是存在这样一个问题,我们花了 4 台机器,但是最终被利用起来的也就一台,主库.这样硬件利用率才 25%,这意味着除非发生故障,不然其他几台机器都是摆设.明显的 ...
- MySQL读写分离高可用集群及读操作负载均衡(Centos7)
目录 概述 keepalived和heartbeat对比 一.环境 二.部署 部署lvs代理和keepalived MySQL+heartbeat+drbd的部署 MySQL主从复制 web服务器及a ...
- mysql读写分离[高可用]
顾名思义, 在mysql负载均衡中有多种方式, 本人愚钝,只了解驱动中间件和mysql_proxy两种方式, 对于驱动,利用的是ReplicationDriver,具体请看远哥的这篇文章: MySQL ...
- MHA+ProxySQL 读写分离高可用
文档结构如下: 1.ProxySQL说明 ProxySQL是mysql的一款中间件的产品,是灵活的mysql代理层,可以实现读写分离,支持query路由器的功能,支持动态指定sql进行缓存,支持动态加 ...
- MySQL主从复制与Atlas读写分离
配置主从复制 1. 增加主从配置 # 主库配置文件 server-id = 1 log-bin = /var/lib/mysql/mysql-bin expire_logs_days = 10 ski ...
- centos 7 Atlas keepalived 实现高可用 MySQL 5.7 MHA环境读写分离
目录 简介 相关链接 环境准备 Atlas 环境 MySQL 集群环境 Atlas 安装 和 配置 为数据库的密码加密 修改配置文件 启动 Keepalived 安装配置 安装 master 配置 K ...
- MHA高可用架构与Atlas读写分离
1.1 MHA简介 1.1.1 MHA软件介绍 MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton ...
- MySQL-18-MHA+Atlas读写分离架构
Atlas介绍 Atlas是由Qihoo 360 Web平台部基础架构团队开发维护的一个基于MySQL协议的数据中间层项目 它是在mysql-proxy 0.8.2版本的基础上,对其进行了优化,增加了 ...
随机推荐
- css3--单行、多行文本溢出
<style> .div1 { width: 200px; height: 200px; background: red url(img/user.png) no-repeat; text ...
- Amber learning note A8: Loop Dynamics of the HIV-1 Integrase Core Domain
1. Prepare Input File $ tleap >source leaprc.protein.ff14SB ----- Source: /home/wangq/Programs/am ...
- 原型链(_proto_) 与原型(prototype) 有啥关系?
prototype对象里面方法及属性是共享的...... 1.JavaScript 中每一个对象都拥有原型链(__proto__)指向其构造函数的原型( prototype),object._prot ...
- 第二章 CSS基本属性
1.CSS:层叠样式表 一个元素允许同时应用多种样式,页面元素最终的样式即为多种样式的叠加效果. 2.CSS样式优先级 行内样式表>内部样式表>外部样式表[就近原则] id选择器>类 ...
- org.joda.time.DateTime 日期格式
最近一直在使用Java,偶尔一次遇到日期(util)的格式转换,心里还是规矩的写着记忆里面的代码,但是在自己测试的时候发现不正确,具体看了下代码,发现这里使用jota的方式编写,顺道查了一下,做了笔记 ...
- PM2管理工具的使用
linux上PM2可以管理服务程序,防止程序无故关闭,具有程序守护功能,自动重启服务器程序,监控程序等好处,很方便,具体自己去体会! 官网地址: http://pm2.keymetrics.io/ ...
- chromedriver 全屏 翻页 错误
from selenium import webdriver from selenium.common.exceptions import TimeoutException, StaleElement ...
- 2.scrapy安装
A.Anaconda如果已安装,那么可以通过 conda 命令安装 Scrapy,安装命令如下: conda install Scrapy ============================ ...
- Linux服务器---邮件服务openwebmail安装
安装openwebmail openwebmail提供了可视化的邮件管理系统,它运行在Apache环境下. 1.安装必备软件 [root@localhost ~]# yum install –y p ...
- 人工智能深度学习框架MXNet实战:深度神经网络的交通标志识别训练
人工智能深度学习框架MXNet实战:深度神经网络的交通标志识别训练 MXNet 是一个轻量级.可移植.灵活的分布式深度学习框架,2017 年 1 月 23 日,该项目进入 Apache 基金会,成为 ...