惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
V
Visual Studio Blog
美团技术团队
L
LINUX DO - 最新话题
Last Week in AI
Last Week in AI
雷峰网
雷峰网
博客园_首页
腾讯CDC
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
人人都是产品经理
人人都是产品经理
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
J
Java Code Geeks
W
WeLiveSecurity
Apple Machine Learning Research
Apple Machine Learning Research
Spread Privacy
Spread Privacy
博客园 - 聂微东
量子位
Recent Announcements
Recent Announcements
S
Schneier on Security
O
OpenAI News
PCI Perspectives
PCI Perspectives
H
Heimdal Security Blog
T
Tailwind CSS Blog
S
Security Affairs
Y
Y Combinator Blog
P
Privacy International News Feed
Hacker News: Ask HN
Hacker News: Ask HN
Stack Overflow Blog
Stack Overflow Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
U
Unit 42
Webroot Blog
Webroot Blog
Vercel News
Vercel News
Simon Willison's Weblog
Simon Willison's Weblog
B
Blog RSS Feed
S
Secure Thoughts
Microsoft Azure Blog
Microsoft Azure Blog
N
Netflix TechBlog - Medium
V
V2EX
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
DataBreaches.Net
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
L
LangChain Blog
S
Security @ Cisco Blogs
The Hacker News
The Hacker News
The GitHub Blog
The GitHub Blog
C
CERT Recently Published Vulnerability Notes

博客园 - 迷你软件

Test post from Metablog Api 博文阅读密码验证 - 博客园 ASP.NET中的Menu控件在谷歌浏览器下显示异常的解决办法 符合标准的正常工作的对联广告(漂浮广告JS代码) C#:按钮颜色设置 用相对定位实现简单的图片边框阴影效果 如何识别 SQL Server 的版本 2010最危险的编程错误(转) NopCommerce学习:MSSQL 2005 排序规则导致中文编码错误 URL解码时,为什么将加号解码为空? 获取本机MAC地址 IPv4 to Integer C# 用SQL语句执行存储过程 1.3.6.1.2.1 - SNMP MIB-2 MIB MODULE HOST-RESOURCES-MIB Simple SNMP with SimpleSnmp 浅谈多线程中数据的绑定和赋值 - 迷你软件 - 博客园 SNMP基础简介 SNMP windows OIDs
MySQL 主从同步延迟监控
迷你软件 · 2022-09-25 · via 博客园 - 迷你软件

MySQL5.7和8.0支持通过 replication_applier_status 表获同步延迟时间,当从库出现延迟后,该表中的字段 REMAINING_DELAY 记录延迟秒数,当没有延迟时,该字段值为NULL,官方对该字段介绍如下:

REMAINING_DELAY If the replica is waiting for DESIRED_DELAY seconds to pass since the source applied an event, this field contains the number of delay seconds remaining. At other times, this field is NULL. (The DESIRED_DELAY value is stored in the replication_applier_configuration table.)

官方介绍:https://dev.mysql.com/doc/mysql-perfschema-excerpt/5.7/en/performance-schema-replication-applier-status-table.html

因此,我们可以监控该字段判断是否有延迟,当有延迟时,通知相关人处理。

最简单的办法是通过现有的监控工具来监控。

第一步: 

注册监控账号,有邮箱就能注册,很简单,网址:https://dataalert.cn/

第二步: 

选择数据源,点击右上角添加

 

注意:数据源中的数据库需要指定 performance_schema

第三步: 

选择监控配置,点击右上角添加

 

上面配置表示从早上8:00到晚上20:59之间,每10分钟监控一次 replication_applier_status 表中的 REMAINING_DELAY 字段的值。

第四步: 

配置异常告警,点击告警规则进行配置

上面配置表示,只要监控的REMAINING_DELAY值大于1,就会进行报警。

第五步:

配置报警接收人,先配置订阅者,再到监控配置中选择订阅 

注:订阅地址为钉钉群的自定义机器人Webhook,获取方式参考(只看文章中的步骤一): https://open.dingtalk.com/document/robots/custom-robot-access

 

选择上一步配置好的订阅者即可,此时,当有告警时会通知到对应的钉钉群,可以在群里直接进行告警后续出处理。

至此,监控搞定~


你也可以在首页看到相关统计数据即告警信息等。

 

当然,该方法除了监控MySQL同步延迟外,还可监控所有基于数据库的数据,如订单量监控,新增用户数监控等各种业务指标监控,对监控的数据也可以配置报告,定时推送监控指标。

传送门:https://dataalert.cn