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线程看下

收到告警配置完成

相关推荐
江南风月2 天前
如何使用WGCLOUD实现智能运维
运维·zabbix·运维开发·prometheus
凤山老林5 天前
可观测性落地:Spring Boot 3.x + Actuator + Prometheus + Grafana 监控体系搭建
spring boot·grafana·prometheus
企鹅郁金香7 天前
部署搭建 Prometheus 和 Grafana教程
eureka·grafana·prometheus
云边有个稻草人7 天前
Ubuntu部署Prometheus与Alertmanager:服务接入和远程监控
数据库·ubuntu·prometheus
雨辰AI9 天前
K8s 国产数据库慢 SQL 自动监控|Prometheus+Grafana 可视化全落地
数据库·sql·安全·容器·kubernetes·grafana·prometheus
lee_curry9 天前
RuoYi Cloud:Gateway、Auth、System 接入 Prometheus JVM 监控,并练习多副本、滚动升级和故障恢复
jvm·gateway·prometheus
晨陌y10 天前
redis_exporter + Prometheus监控Redis: 指标采集、告警与远程抓取
redis·bootstrap·prometheus
lee_curry14 天前
kube-prometheus-stack 87.21.0 部署
prometheus
扶疏52514 天前
Prometheus+Prometheus Adapter+metrics-server+Ingress实现k8s水平自动扩缩容(HPA)
容器·kubernetes·prometheus
奔跑中的小象14 天前
UOS V2500 沐曦mx-exporter监控加速卡(非K8S)
grafana·prometheus·uos·vllm·沐曦