下载安装mysql_exporter
cd /usr/local
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
tar -zxvf mysqld_exporter-0.12.1.linux-amd64.tar.gz
mv mysqld_exporter-0.12.1.linux-amd64 mysqld_exporter
mysql的pxc集群添加账号密码:
GRANT REPLICATION CLIENT, PROCESS ON . TO 'exporter'@'localhost' identified by '123456';
GRANT SELECT ON performance_schema.* TO 'exporter'@'localhost';
flush privileges;
[root@pxc1 mysqld_exporter]# cat .my.cnf
[client]
host=192.168.7.201
user=exporter
password=123456
启动:
nohup ./mysqld_exporter --config.my-cnf=.my.cnf &
复制
Prometheus配置
- job_name: 'mysql-cluster'
static_configs:
- targets:
- '192.168.7.201:9104'
- '192.168.7.202:9104'
- '192.168.7.203:9104'
报警:
############ mysql 监控 ############
- alert: MySQLGaleraNotReady
expr: mysql_global_status_wsrep_ready != 1
for: 5m
labels:
severity: warning
annotations:
description: "{{$labels.job}} on {{$labels.instance}} is not ready."
summary: "Galera cluster node not ready"
- alert: MySQLGaleraOutOfSync
expr: (mysql_global_status_wsrep_local_state != 4 and mysql_global_variables_wsrep_desync == 0)
for: 5m
labels:
severity: warning
annotations:
description: "{{$labels.job}} on {{$labels.instance}} is not in sync ({{$value}}!= 4)."
summary: "Galera cluster node out of sync"
- alert: MySQL is down
expr: mysql_up == 0
for: 1m
labels:
severity: critical
annotations:
description: "Instance {{ $labels.instance }} MySQL is down"
summary: "MySQL database is down. This requires immediate action!"
- alert: MySql 连接数超过最大连接数的80%
expr: mysql_global_status_max_used_connections > mysql_global_variables_max_connections * 0.8
for: 2m
labels:
severity: warning
annotations:
description: "Instance {{ $labels.instance }} Used more than 80% of max connections limited"
summary: "Used more than 80% of max connections limited"
复制
grafana导入模板
https://grafana.com/grafana/dashboards/7362 mysql插件
https://grafana.com/grafana/dashboards/7377 pxc插件
文章转载自云原生数字化,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
墨天轮个人数说知识点合集
JiekeXu
411次阅读
2025-04-01 15:56:03
MySQL数据库当前和历史事务分析
听见风的声音
409次阅读
2025-04-01 08:47:17
MySQL 生产实践-Update 二级索引导致的性能问题排查
chengang
370次阅读
2025-03-28 16:28:31
MySQL 9.3 正式 GA,我却大失所望,新特性亮点与隐忧并存?
JiekeXu
327次阅读
2025-04-15 23:49:58
3月“墨力原创作者计划”获奖名单公布
墨天轮编辑部
320次阅读
2025-04-15 14:48:05
【活动】分享你的压箱底干货文档,三篇解锁进阶奖励!
墨天轮编辑部
311次阅读
2025-04-17 17:02:24
云和恩墨杨明翰:安全生产系列之MySQL高危操作
墨天轮编辑部
293次阅读
2025-03-27 16:45:26
openHalo问世,全球首款基于PostgreSQL兼容MySQL协议的国产开源数据库
严少安
269次阅读
2025-04-07 12:14:29
记录MySQL数据库的一些奇怪的迁移需求!
陈举超
176次阅读
2025-04-15 15:27:53
[MYSQL] 服务器出现大量的TIME_WAIT, 每天凌晨就清零了
大大刺猬
171次阅读
2025-04-01 16:20:44