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

收到告警配置完成

相关推荐
chaodaibing3 天前
elasticsearch_exporter启动报错 failed to fetch and decode node stats
elasticsearch·prometheus
陌殇殇殇4 天前
Prometheus监控MySQL主从数据库
运维·数据库·mysql·prometheus
福大大架构师每日一题4 天前
19.1 使用k8s的sdk编写一个项目获取pod和node信息
云原生·容器·kubernetes·prometheus
福大大架构师每日一题4 天前
19.3 打镜像部署到k8s中,prometheus配置采集并在grafana看图
kubernetes·grafana·prometheus
福大大架构师每日一题5 天前
21.2 k8s中etcd的tls双向认证原理解析
容器·kubernetes·prometheus·etcd
我的运维人生5 天前
基于Prometheus和Grafana的现代服务器监控体系构建
服务器·运维开发·grafana·prometheus·技术共享
BUG弄潮儿5 天前
k8s 部署 prometheus
容器·kubernetes·prometheus
iQM756 天前
基于Prometheus和Grafana的现代服务器监控体系构建
服务器·grafana·prometheus
kayotin8 天前
使用Prometheus进行系统监控,包括Mysql、Redis,并使用Grafana图形化表示
redis·mysql·prometheus
人类群星闪耀时9 天前
监控和日志管理:深入了解Nagios、Zabbix和Prometheus
zabbix·prometheus