prometheus监控mysql8.x以及主从监控告警

mysql8.x主从部署请看下面文档 docker和yum安装的都有

Docker部署mysql8.x版本互为主从_争取不加班!的博客-CSDN博客

Mysql8.x版本主从加读写分离(一) mysql8.x主从_myswl8双主一从读写分离_争取不加班!的博客-CSDN博客

安装部署mysqld_exporter

wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.13.0/mysqld_exporter-0.13.0.linux-amd64.tar.gz

tar -xvzf mysqld_exporter-0.13.0.linux-amd64.tar.gz -C /usr/local/

cd /usr/local/mysqld_exporter-0.13.0.linux-amd64/

vim ./my.cnf 编辑一个文件 启动exporter的用户和密码

client

host=localhost 监控其他主机换成ip即可

user=root 注意用户权限 创建一个有权限的用户

port=3306

password=Zxcvbnm@2022

nohup ./mysqld_exporter --config.my-cnf=./my.cnf --web.listen-address=":9104" 指定端口

& 运行

--web.listen-address=":9104" 运行多个的话指定其他端口即可

ps -ef |grep mysqld_exporter

kill -9 114835 关闭

然后编辑prometheus配置配件

vim prometheus.yml

systemctl restart prometheus 重启

启动mysql_exporter

vim nohup 看一下启动日志

192.168.11.193:9104/metrics 启动后查看 有数据则启动成功

以上配置好以后在Grafana中配置mysql的监控模板

在Grafana官网中下载mysql的监控模板 Dashboards | Grafana Labs

下载好以后来到GrafanaWEB页面

配置完成!!!

Grafana mysql8.x监控模板id 14057

然后编写mysql的告警规则

#mysql服务挂掉时触发告警

  • alert: Mysql状态

expr: mysql_up == 0

for: 10s

labels:

severity: warning

annotations:

summary: ' {{ $labels.instance }} Mysql服务 '

description: " {{ $labels.instance }} Mysql服务不可用 请检查"

#mysql主从IO线程停止时触发告警

  • alert: Mysql主从IO线程检测

expr: mysql_slave_status_slave_io_running == 0

for: 5s

labels:

severity: error

annotations:

summary: " {{ $labels.instance }} Mysql从节点IO线程"

description: "Mysql主从IO线程故障,请检测"

#mysql主从sql线程停止时触发告警

  • alert: Mysql主从sql线程检测

expr: mysql_slave_status_slave_sql_running == 0

for: 5s

labels:

severity: error

annotations:

summary: "{{ $labels.instance }} Mysql从节点sql线程"

description: "Mysql主从sql线程故障,请检测"

systemctl restart alertmanager prometheus 重启 alertmanager和 prometheus

stop slave sql_thread; 停掉 从库的sql线程看下

收到告警配置完成

相关推荐
liuyicenysabel11 小时前
Grafana + Prometheus 分级告警配置设计(P0/P1/P2)
javascript·grafana·prometheus
随遇而安zx11 小时前
SpringCloud---可观测性与监控:Actuator / Micrometer / Prometheus / Grafana 深度解析
spring cloud·grafana·prometheus
qq_4523962313 小时前
第四篇:《Prometheus 深度实战:指标设计、Exporter 开发与服务发现》
服务发现·prometheus
刘某的Cloud15 小时前
k8s部署prometheus架构规则
linux·运维·kubernetes·prometheus·监控
LlmCraft|大模型工程实践17 小时前
12. Docker 日志管理与监控:ELK 日志收集 + Prometheus 性能监控
elk·docker·prometheus
DevOps老兵1 天前
AI Infra实战02:GPU监控实战,用DCGM+Prometheus+Grafana看清每一张卡
人工智能·grafana·prometheus·ai infra·gpu监控·dcgm
heimeiyingwang1 天前
【Prometheus·入门篇】数据模型:Metric 类型、标签与时间序列
prometheus
heimeiyingwang2 天前
【Prometheus·部署篇】配置详解:scrape_config、relabeling 与服务发现
prometheus
heimeiyingwang5 天前
【Prometheus·入门篇】Prometheus 是什么:从 Nagios 到云原生监控的演进
prometheus
秋风点枝6 天前
第一篇:认识 Prometheus —— 云原生监控的基础
云原生·prometheus