使用Prometheus+Grafana监控MySQL

news/2025/2/24 2:39:00/文章来源:https://www.cnblogs.com/minseo/p/18714971

前提

  • 搭建好Prometheus
    本次使用Docker搭建
    https://www.cnblogs.com/minseo/p/17913003.html

  • 搭建好Grafana

  1. 环境查看
    系统环境
# cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)
# uname -a
Linux CentOS7K8SHarbor061 3.10.0-1160.102.1.el7.x86_64 #1 SMP Tue Oct 17 15:42:21 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

软件环境
Prometheus版本
image
mysqld_exporter版本

# ./mysqld_exporter --version
mysqld_exporter, version 0.14.0 (branch: HEAD, revision: ca1b9af82a471c849c529eb8aadb1aac73e7b68c)build user:       root@401d370ca42ebuild date:       20220304-16:25:15go version:       go1.17.8platform:         linux/amd64
  1. 配置MySQL监控
    下载mysqld_exporter
    下载地址
    https://github.com/prometheus/mysqld_exporter/releases
    本次下载0.14.0版本
    下载后解压缩启动
# 解压
# tar -xf mysqld_exporter-0.14.0.linux-amd64.tar.gz 
# cd mysqld_exporter-0.14.0.linux-amd64/
# 带配置文件启动
# ./mysqld_exporter --config.my-cnf=/etc/.my.cnf &

配置文件需要添加数据库信息

# cat /etc/.my.cnf 
[client]
user=root
password=root
host=localhost
port=3306

image
3. 修改prometheus配置文件
修改配置文件添加监控客户端
本次使用的是docker启动修改挂载的配置文件

# cat /data/softs/prometheus/prometheus.yml 
# my global config
global:scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.# scrape_timeout is set to the global default (10s).# Alertmanager configuration
alerting:alertmanagers:- static_configs:- targets:# - alertmanager:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:# - "first_rules.yml"# - "second_rules.yml"# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.- job_name: "prometheus"# metrics_path defaults to '/metrics'# scheme defaults to 'http'.static_configs:- targets: ["localhost:9090",'192.168.3.61:9100','192.168.3.62:9100','192.168.3.63:9100','192.168.3.64:9100','192.168.3.65:9100','192.168.3.66:9100','192.168.3.67:9100','192.168.3.68:9100','192.168.3.69:9100','192.168.3.70:9100']- job_name: "mysql"static_configs:- targets: ["192.168.3.204:9104"]

本次添加以下配置
image
重启对应容器使配置生效

# docker restart prometheus
  1. Grafana添加仪表盘
    下载监控Json模板
    下载地址
    https://grafana.com/grafana/dashboards/7362-mysql-overview/
    Grafana导入仪表盘
    image
    image
    查看监控项
    image

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/883631.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

centos7安装mysql5.6.43报错解决方案!

今天虚拟机安装mysql-community-server-5.6.43版本时出现依赖报错,按照提示的error进行解决! 第一个问题是 Requires: libaio.so.1()(64bit) 解决方案:确保机器联网,使用 yum install -y libaio 第二个问题是缺少perl依赖,可以使用 yum install -y perl* peri-* 安装 这条…

利用apache2本地搭建web环境

下载apache2服务sudo apt install apache2 php -y 启动apache2sudo service apache2 restart命令执行后即可在浏览器访问,访问localhost或127.0.0.1(默认端口为80)即可看到apache的默认页面说明本地站点搭建完毕目录:/var/www/html这个目录下存放的是网站的资源,图片或html…

rancher页面无法显示pod实时日志

异常现象rancher无法通过web页面查看相关pod日志排查步骤1.在k8s的主节点上执行查看日志的命令kubectl get pods -n smartroom-testkubectl logs -f register-85dbdc6df8-nqkc4 -n smartroom-test在k8s主节点上无法查看其它node上运行的pod的运行日志2.在pod运行的主机上查看容…

十. 数据结构

数据结构 二叉树遍历先序遍历:根左右 中序遍历:左根右 后序遍历:左右根 层序遍历:从上到下、从左往右依次遍历通过序列构造二叉树必须有中序序列先序遍历中序遍历后序遍历图的遍历查找哈希表散列表(Hash table, 也叫哈希表), 是根据关键码值(key value)而直接进行访问的数…

微信小程序-引入less

介绍 微信开发者工具默认样式文件是wxss,但该文件格式不支持层级嵌套写法,为了支持此功能可以引入less 或者 sass,微信开发者工具默认不支持less,需要自己安装插件。 Less(Leaner Style Sheets 的缩写)是一种动态样式语言,属于 CSS 预处理器的范畴,它扩展了 CSS 语言,…

unity毛笔笔锋

using System;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI; namespace LastZero.Utility{public class Painting : MonoBehaviour{public Color mColor = Color.black;//画笔颜色//[HideInInspector]public Texture brushTexture;//画笔[HideInI…

.NET 8.0 + Linux 香橙派,实现高效的 IoT 数据采集与控制解决方案

前言 随着物联网(IoT)技术的迅猛发展,智能设备之间的互联互通变得越来越重要。 推荐一套基于 C# 的高效 IoT 系统,该系统运行在 Linux 开发板上,并支持 Modbus RS485 传感器、NPN/PNP 开关等所有符合 485 通讯协议的设备进行数据采集和指令发送。这套系统在为智能家居、智…

DeepSeek 背后的技术:GRPO,基于群组采样的高效大语言模型强化学习训练方法详解

强化学习(Reinforcement Learning, RL)已成为提升大型语言模型(Large Language Models, LLMs)推理能力的重要技术手段,特别是在需要复杂推理的任务中。DeepSeek 团队在 DeepSeek-Math [2] 和 DeepSeek-R1 [3] 模型中的突破性成果,充分展示了强化学习在增强语言模型数学推…

https://avoid.overfit.cn/post/05d4b8fb001b4adeb4e050fb323cd21f

强化学习(Reinforcement Learning, RL)已成为提升大型语言模型(Large Language Models, LLMs)推理能力的重要技术手段,特别是在需要复杂推理的任务中。DeepSeek 团队在 DeepSeek-Math [2] 和 DeepSeek-R1 [3] 模型中的突破性成果,充分展示了强化学习在增强语言模型数学推…

DeepSeek 杀红眼了!GPT-5 宣布免费,百度文心一言宣布免费。。。大快人心!

大家好,我是R哥。 最近的科技圈可谓风起云涌,横空出世的 DeepSeek 自从它发布以来,不但打破了业界的格局,还引发了一系列连锁反应。 如果你还没用过 DeepSeek,清华大学出的《DeepSeek 从入门到精通》推荐你好好看看吧,质量非常高,从原理到应用实践,写得非常好。 DeepSe…

CppQt3D-DataVisualization Simple LorenzSystem By Q3DScatter

环境搭建: Qt 6.7.2 MSVC 2019 64bit CMake latest find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Core Core5Compat DataVisualization)#executable(...) 之后target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSI…