MySQL 监控-innotop
1、pt-heartbeat的作用
pt-heartbeat measures replication lag on a MySQL or PostgreSQL server. You can use it to update a master or monitor a replica. If possible, MySQL connection options are read from your .my.cnf file. For more details, please use the --help option, or try 'perldoc /usr/bin/pt-heartbeat' for complete documentation.
pt-heartbeat is a two-part MySQL and PostgreSQL replication delay monitoring system that measures delay by looking at actual replicated data. This avoids reliance on the replication mechanism itself, which is unreliable. (For example, SHOW SLAVE STATUS on MySQL).
2、pt-heartbeat的原理
The first part is an --update instance of pt-heartbeat that connects to a master and updates a timestamp (“heartbeat record”) every --interval seconds. Since the heartbeat table may contain records from multiple masters (see “MULTI-SLAVE HIERARCHY”), the server’s ID (@@server_id) is used to identify records.
主库上存在一个用于检查延迟的表heartbeat,可手动或自动创建
pt-heartbeat使用--update参数连接到主库上并持续(根据设定的--interval参数)使用一个时间戳更新到表heartbeat
The second part is a --monitor or --check instance of pt-heartbeat that connects to a slave, examines the replicated heartbeat record from its immediate master or the specified --master-server-id, and computes the difference from the current system time. If replication between the slave and the master is delayed or broken, the computed difference will be greater than zero and otentially increase if --monitor is specified.
pt-heartbeat使用--monitor 或--check连接到从库,检查从主库同步过来的时间戳,并与当前系统时间戳进行比对产生一个差值,
该值则用于判断延迟。(注,前提条件是主库与从库应保持时间同步)
You must either manually create the heartbeat table on the master or use --create-table. See --create-table for the proper heartbeat table structure. The MEMORY storage engine is suggested, but not re-quired of course, for MySQL.
The heartbeat table must contain a heartbeat row. By default, a heartbeat row is inserted if it doesn’t exist. This feature can be disabled with the --[no]insert-heartbeat-row option in case the database user does not have INSERT privileges.
pt-heartbeat depends only on the heartbeat record being replicated to the slave, so it works regardless of the replication mechanism (built-in replication, a system such as Continuent Tungsten, etc). It works at any depth in the replication hierarchy; for example, it will reliably report how far a slave lags its master’s master’s master. And if replication is stopped, it will continue to work and report (accurately!) that the slave is falling further and further behind the master.
pt-heartbeat has a maximum resolution of 0.01 second. The clocks on the master and slave servers must be closely synchronized via NTP. By default, --update checks happen on the edge of the second (e.g. 00:01) and --monitor checks happen halfway between seconds (e.g. 00:01.5). As long as the servers’ clocks are closely synchronized and replication events are propagating in less than half a second, pt-heartbeat will report zero seconds of delay.
pt-heartbeat will try to reconnect if the connection has an error, but will not retry if it can’t get a connection when it first starts.
The --dbi-driver option lets you use pt-heartbeat to monitor PostgreSQL as well. It is reported to work well with Slony-1 replication.
3、获取pt-heartbeat帮助信息
a、获取帮助信息
[root@DBMASTER01 ~]# pt-heartbeat #直接输入pt-heartbeat可获得一个简要描述,使用pt-heartbeat --help获得一个完整帮助信息
Usage: pt-heartbeat [OPTIONS] [DSN] --update|--monitor|--check|--stop
Errors in command-line arguments:
* Specify at least one of --stop, --update, --monitor or --check
* --database must be specified
4、演示使用pt-heartbeat
a、首先添加表
[root@DBMASTER01 ~]# pt-heartbeat --user=root --password=xxx -S /tmp/mysql.sock -D test --master-server-id=11 --create-table --update
MASTER> select * from heartbeat;
+----------------------------+-----------+------------------+-----------+-----------------------+---------------------+
| ts | server_id | file | position | relay_master_log_file | exec_master_log_pos |
+----------------------------+-----------+------------------+-----------+-----------------------+---------------------+
| 2014-12-01T09:48:14.003020 | 11 | mysql-bin.000390 | 677136957 | mysql-bin.000179 | 120 |
+----------------------------+-----------+------------------+-----------+-----------------------+---------------------+
b、更新主库上的heartbeat
[root@DBMASTER01 ~]# pt-heartbeat --user=root --password=xxx -S /tmp/mysql.sock -D test --master-server-id=11 --update &
[1] 31249
c、从库上监控延迟
[root@DBBAK01 ~]# pt-heartbeat --user=root --password=xxx -S /tmp/mysql.sock -D test --master-server-id=11 --monitor --print-master-server-id
1.00s [ 0.02s, 0.00s, 0.00s ] 11 #实时延迟,1分钟延迟,5分钟延迟,15分钟延迟
1.00s [ 0.03s, 0.01s, 0.00s ] 11
1.00s [ 0.05s, 0.01s, 0.00s ] 11
1.00s [ 0.07s, 0.01s, 0.00s ] 11
1.00s [ 0.08s, 0.02s, 0.01s ] 11
1.00s [ 0.10s, 0.02s, 0.01s ] 11
1.00s [ 0.12s, 0.02s, 0.01s ] 11
1.00s [ 0.13s, 0.03s, 0.01s ] 11
d、其他操作示例
#将主库上的update使用守护进程方式调度
[root@DBMASTER01 ~]# pt-heartbeat --user=root --password=xxx -S /tmp/mysql.sock -D test --master-server-id=11 --update --daemonize
#修改主库上的更新间隔为2s
[root@DBMASTER01 ~]# pt-heartbeat --user=root --password=xxx -S /tmp/mysql.sock -D test --master-server-id=11 --update --daemonize --interval=2
#停止主库上的pt-heartbeat守护进程
[root@DBMASTER01 ~]# pt-heartbeat --stop
Successfully created file /tmp/pt-heartbeat-sentinel
[root@DBMASTER01 ~]# rm -rf /tmp/pt-heartbeat-sentinel
#单次查看从库上的延迟情况
[robin@DBBAK01 ~]$ pt-heartbeat --user=root --password=xxx -S /tmp/mysql.sock -D test --master-server-id=11 --check
1.00
#使用守护进程监控从库并输出日志
[root@DBBAK01 ~]# pt-heartbeat --user=root --password=xxx -S /tmp/mysql.sock -D test --master-server-id=11 --monitor --print-master-server-id --daemonize --log=/tmp/slave-lag.log
MySQL 监控-innotop的更多相关文章
- MySQL监控工具——innotop
MySQL监控工具--innotop innotop是一个mysql数据库实时监控工具,其功能强大,信息种类繁多,很能体现数据库的状态. 它实际上是一个perl脚本,整合show status/sho ...
- mysql监控管理工具--innotop
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/innotop/innotop-1.9. ...
- MySQL监控、性能分析——工具篇
https://blog.csdn.net/leamonjxl/article/details/6431444 MySQL越来越被更多企业接受,随着企业发展,MySQL存储数据日益膨胀,MySQL的性 ...
- MySQL监控、性能分析——工具篇(转载)
MySQL越来越被更多企业接受,随着企业发展,MySQL存储数据日益膨胀,MySQL的性能分析.监控预警.容量扩展议题越来越多.“工欲善其事,必先利其器”,那么我们如何在进行MySQL性能分析.监控预 ...
- 如何在Zabbix上安装MySQL监控插件PMP
PMP,全称是Percona Monitoring Plugins,是Percona公司为MySQL监控写的插件.支持Nagios,Cacti.从PMP 1.1开始,支持Zabbix. 下面,看看如何 ...
- DB监控-mysql监控
Mysql监控属于DB监控的模块之一,包括采集.展示.监控告警.本文主要介绍Mysql监控的主要指标和采集方法. Mysql监控和Redis监控的逻辑类似,可参考文章<Redis监控>. ...
- 分布式监控系统Zabbix-3.0.3-完整安装记录(2)-添加mysql监控
Zabbix3.0 Server以后就自带了MySQL插件来监控mysql数据库的模板,只需要配置好agent客户端,然后在web端给主机增加模板就行了. 以下是公司线上的zabbix3.0环境下添加 ...
- 详解 Spotlight on MySQL监控MySQL服务器
前一章详解了Spotlight on Unix 监控Linux服务器 ,今天再来看看Spotlight on MySQL怎么监控MySQL服务器. 注:http://www.cnblogs.com/J ...
- 京东MySQL监控之Zabbix优化、自动化
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://wangwei007.blog.51cto.com/68019/1833332 随 ...
随机推荐
- Python操作MySQL数据库完成简易的增删改查功能
说明:该篇博客是博主一字一码编写的,实属不易,请尊重原创,谢谢大家! 目录 一丶项目介绍 二丶效果展示 三丶数据准备 四丶代码实现 五丶完整代码 一丶项目介绍 1.叙述 博主闲暇之余花了10个小时写的 ...
- Flask项目之手机端租房网站的实战开发(十四)
说明:该篇博客是博主一字一码编写的,实属不易,请尊重原创,谢谢大家! 接着上一篇博客继续往下写 :https://blog.csdn.net/qq_41782425/article/details/8 ...
- 【习题 7-2 UVA-225】Golygons
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 暴力枚举每次走哪里就好. 用一个二维数组来判重.(数据里,要求不能经过一个点两次->但路径可以相交 然后再用一个flag数组, ...
- WPF 入门《布局面板》
常见的几个布局面板 1.StackPanel面板 StackPanel面板能够简单根据单行或者单列进行元素排列, StackPanel 默认的布局方向为垂直方向(Vertical), 由Orienta ...
- 10.Maven依赖排除 禁止依赖传递 取消依赖的方法
转自:https://www.cnblogs.com/duanxz/p/6084494.html 大家都知道Maven的优点是依赖管理,特别是前期使用ANT的开发者都有很多感触.最近要开发一个java ...
- golang iota
package main import ( "fmt" ) const ( Low = * (iota + ) Medium High ) func main() { //iota ...
- COGS——C2274. [HEOI 2016] tree
http://www.cogs.pro/cogs/problem/problem.php?pid=2274 ★☆ 输入文件:heoi2016_tree.in 输出文件:heoi2016_tre ...
- Numpy库进阶教程(一)求解线性方程组
前言 Numpy是一个很强大的python科学计算库.为了机器学习的须要.想深入研究一下Numpy库的使用方法.用这个系列的博客.记录下我的学习过程. 系列: Numpy库进阶教程(二) 正在持续更新 ...
- 微信支付v2开发(7) 告警通知
本文介绍微信支付中如何获得告警通知. 一.告警通知 为了及时通知商户异常,提高商户在微信平台的服务质量.微信后台会向商户推送告警通知,包括发货延迟.调用失败.通知失败等情况,通知的地址是商户在申请支付 ...
- sql语句的编程手册 SQL PLUS
一.SQL PLUS 引言 SQL命令 以下17个是作为语句开头的关键字: alter drop revoke audit grant rollback* commit* insert select ...