mysqld_exporter集中部署

集中部署,就是说我们将所有的mysqld_exporter部署在同一台服务器上,在这台服务器上对mysqld_exporter进行统一的管理,下面介绍一下集中部署的方法。这里我们专门起一台IP为172.18.0.23的服务器,另外两台172.18.0.11和172.18.0.13作为2个MySQL节点。

在172.18.0.23上下载安装mysqld_exporter

添加172.18.0.11节点

1、在172.18.0.11上建立监控用户

GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT, RELOAD ON *.* TO 'pmm'@'%' IDENTIFIED BY 'pmm';

2、在172.18.0.23上编辑172.18.0.11节点的配置文件

[root@mysqld_exporter-23 /]# cd /data/mysqld_exporter/
[root@mysqld_exporter-23 mysqld_exporter]# cat etc/.dk-11.cnf
[client]
user=pmm
password=pmm
host=172.18.0.11
port=3306

3、在172.18.0.23上启动mysqld_exporter

[root@mysqld_exporter-23 ~]# cd /data/mysqld_exporter/
[root@mysqld_exporter-23 mysqld_exporter]# nohup ./mysqld_exporter --web.listen-address=172.18.0.23:9104 --config.my-cnf=etc/.dk-11.cnf --collect.auto_increment.columns --collect.binlog_size --collect.global_status --collect.global_variables --collect.info_schema.innodb_metrics --collect.info_schema.innodb_cmp --collect.info_schema.innodb_cmpmem --collect.info_schema.processlist --collect.info_schema.query_response_time --collect.info_schema.tables --collect.info_schema.tablestats --collect.info_schema.userstats --collect.perf_schema.eventswaits --collect.perf_schema.file_events --collect.perf_schema.indexiowaits --collect.perf_schema.tableiowaits --collect.perf_schema.tablelocks --collect.slave_status &

这里看到mysqld_exporter的启动多了两个选项,"--web.listen-address"和"--config.my-cnf"。

web.listen-address代表这个mysqld_exporter进程绑定的端口,以供prometheus调用,这里暴露的是172.18.0.23的9104端口。

config.my-cnf代表这个mysqld_exporter进程监控的MySQL的连接信息。

4、在prometheus服务器配置prometheus文件

[root@prometheus-21 /]# cd /data/prometheus/
[root@prometheus-21 prometheus]# cat 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. # A scrape configuration containing exactly one endpoint to scrape:
scrape_configs:
- file_sd_configs:
- files:
- mysql.yml
job_name: MySQL
metrics_path: /metrics
relabel_configs:
- source_labels: [__address__]
regex: (.*)
target_label: __address__
replacement: $1

5、在prometheus服务器配置mysql.yml文件

[root@prometheus-21 prometheus]# cat mysql.yml
- labels:
instance: dk-11:3306 # grafana显示的实例的别名
targets:
- 172.18.0.23:9104 # mysqld_exporter暴露的端口

mysql.yml的172.18.0.23:9104会通过prometheus配置文件中的file_sd_configs配置,作为变量传给$1,然后替换__address__,因而被prometheus所识别。

6、使prometheus配置生效

[root@prometheus-21 prometheus]# pgrep -fl prometheus
33 /data/prometheus/prometheus --storage.tsdb.retention=30d
[root@prometheus-21 prometheus]# kill -HUP 33

prometheus.yml文件更改后需要上述操作后生效,mysql.yml修改后prometheus会自动识别。

7、验证172.18.0.11是否添加成功

浏览器输入Prometheus_IP:9090

浏览器输入Grafana_IP:3000

添加172.18.0.13节点

添加新的节点到监控,只需要做4步就可以。

1、在172.18.0.13上建立监控用户

GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT, RELOAD ON *.* TO 'pmm'@'%' IDENTIFIED BY 'pmm';

2、在172.18.0.23上编辑172.18.0.13节点的配置文件

[root@mysqld_exporter-23 /]# cd /data/mysqld_exporter/
[root@mysqld_exporter-23 mysqld_exporter]# cat etc/.dk-13.cnf
[client]
user=pmm
password=pmm
host=172.18.0.13
port=3306

3、在172.18.0.23上启动mysqld_exporter

[root@mysqld_exporter-23 ~]# cd /data/mysqld_exporter/
[root@mysqld_exporter-23 mysqld_exporter]# nohup ./mysqld_exporter --web.listen-address=172.18.0.23:9105 --config.my-cnf=etc/.dk-13.cnf --collect.auto_increment.columns --collect.binlog_size --collect.global_status --collect.global_variables --collect.info_schema.innodb_metrics --collect.info_schema.innodb_cmp --collect.info_schema.innodb_cmpmem --collect.info_schema.processlist --collect.info_schema.query_response_time --collect.info_schema.tables --collect.info_schema.tablestats --collect.info_schema.userstats --collect.perf_schema.eventswaits --collect.perf_schema.file_events --collect.perf_schema.indexiowaits --collect.perf_schema.tableiowaits --collect.perf_schema.tablelocks --collect.slave_status &
# 这里暴露的是9105端口,使用的是.dk-13.cnf的文件。

4.在prometheus服务器配置mysql.yml文件

[root@prometheus-21 prometheus]# cat mysql.yml
- labels:
instance: dk-11:3306
targets:
- 172.18.0.23:9104
- labels:
instance: dk-13:3306
targets:
- 172.18.0.23:9105

只需要添加172.18.0.13的mysqld_exporter对应的端口和别名就可以。

5、验证172.18.0.13是否添加成功

浏览器输入Prometheus_IP:9090

浏览器输入Grafana_IP:3000

集中管理

当我们需要添加新的节点,只需要将新节点的连接信息配置好,划分新的端口,启动mysqld_exporter,然后在prometheus中的mysql.yml文件添加新节点暴露的端口以及新节点的自定义别名就可以了。

这样我们就可以在mysqld_exporter节点上对mysqld_exporter的进程进行统一管理了。

改造

文章地址:https://www.cnblogs.com/sanduzxcvbnm/p/13094580.html

根据这篇文章的讲述,可以稍加改造,使用多个mysqld_exporter.service服务,名称区分开,比如mysqld_exporter1.service,mysqld_exporter2.service等,在每个里面配置上数据库的连接信息

7.prometheus监控多个MySQL实例的更多相关文章

  1. k8s中prometheus监控k8s外mysql

    k8s外安装mysql https://www.cnblogs.com/uncleyong/p/10739530.html 配置MySQL Exporter采集MySQL监控数据 创建yaml文件:v ...

  2. 使用 Docker 部署 Grafana + Prometheus 监控 MySQL 数据库

    一.背景 在平时开发过程当中需要针对 MySQL 数据库进行监控,这里我们可以使用 Grafana 和 Prometheus 来实现监控功能.Grafana 是一款功能强大的仪表盘面板,支持多种数据源 ...

  3. Docker监控平台prometheus和grafana,监控redis,mysql,docker,服务器信息

    Docker监控平台prometheus和grafana,监控redis,mysql,docker,服务器信息 一.通过redis_exporter监控redis 1.1 下载镜像 1.2 运行服务 ...

  4. [k8s]prometheus+grafana监控node和mysql(普罗/grafana均vm安装)

    https://github.com/prometheus/prometheus Architecture overview Prometheus Server Prometheus Server 负 ...

  5. Grafana+Prometheus 监控 MySQL

    转自:Grafana+Prometheus 监控 MySQL 架构图 环境 IP 环境 需装软件 192.168.0.237 mysql-5.7.20 node_exporter-0.15.2.lin ...

  6. Prometheus 监控Mysql服务器及Grafana可视化

    Prometheus 监控Mysql服务器及Grafana可视化. mysql_exporter:用于收集MySQL性能信息. 使用版本 mysqld_exporter 0.11.0 官方地址 使用文 ...

  7. 手把手教你使用 Prometheus 监控 MySQL 与 MariaDB.md

    概述 MySQL 是常用的关系型数据库,MariaDB 作为 MySQL 的分支版本,兼容 MySQL 协议,也越来越流行.在 Kubernetes 环境中如何使用 Prometheus 来对它们进行 ...

  8. Kubernetes容器集群管理环境 - Prometheus监控篇

    一.Prometheus介绍之前已经详细介绍了Kubernetes集群部署篇,今天这里重点说下Kubernetes监控方案-Prometheus+Grafana.Prometheus(普罗米修斯)是一 ...

  9. 使用Prometheus监控SpringBoot应用

    通过之前的文章我们使用Prometheus监控了应用服务器node_exporter,数据库mysqld_exporter,今天我们来监控一下你的应用.(本文以SpringBoot 2.1.9.REL ...

随机推荐

  1. 可控线性序列机(查看除了inout端口外的其他变量的波形的方法)

    可控线性序列机: 可控:有个控制端控制何时输出线性序列. 线性序列机:输出一个线性序列. 知识点: 1.包含多个判定条件时用英文()括起来,用&&连接. 2.使能端EN的设置(类似于D ...

  2. 透过Redis源码探究Hash表的实现

    转载请声明出处哦~,本篇文章发布于luozhiyun的博客:https://www.luozhiyun.com/archives/667 本文使用的Redis 5.0源码 概述 我们在学习 Redis ...

  3. Java的学习日常

    当2020年10月进入大学,我选择了计算机专业,本想着自己会摒弃高中的不良习惯,认真学习.但随着和同学们的熟悉,自己的本性也逐渐暴露出来.两年懒散表现,让现在回过头的自己都不忍直视. 虽然在学习期间, ...

  4. .NET WebAPI 使用 GroupName 对 Controller 分组呈现 Swagger UI

    在日常开发 webapi 时,我们往往会集成 swagger doc 进行 api 的文档呈现,当api数量比较多的时候就会导致 swagger ui 上的 api 因为数量太多而显得杂乱,今天教大家 ...

  5. Frame双向通信插件FrameDataTrans

    FrameDataTrans教程 博客园 乳鸽菌 20220729 核心原理是使用postMessage发送数据,window.addEventListener("message" ...

  6. 轻盈潇洒卓然不群,敏捷编辑器Sublime text 4中文配置Python3开发运行代码环境(Win11+M1 mac)

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_210 20世纪初,几乎所有的飞机都是并列双翼结构,此时,美国著名飞行大亨霍华德·休斯认为自己的飞机不够快,助手委婉地提醒他,如果速 ...

  7. 小白之Python基础(五)

    使用dict和set 1.dict :是direction字典的缩写 1) 通过{ }创建,使用健-值(key-value)存储:用"键值对"表示映射关系,例如 {名字:对应的成绩 ...

  8. 金融任务实例实时、离线跑批Apache DolphinScheduler在新网银行的三大场景与五大优化

    在新网银行,每天都有大量的任务实例产生,其中实时任务占据多数.为了更好地处理任务实例,新网银行在综合考虑之后,选择使用 Apache DolphinScheduler 来完成这项挑战.如今,新网银行多 ...

  9. ceph 006 rbd高级特性 rbd快照 镜像克隆 rbd缓存 rbd增量备份 rbd镜像单向同步

    版本 [root@clienta ~]# ceph -v ceph version 16.2.0-117.el8cp (0e34bb74700060ebfaa22d99b7d2cdc037b28a57 ...

  10. JavaScript(上)

    说说你对作用域链的理解 作用域链的作用是保证执行环境里有权访问的变量和函数是有序的,作用域链的变量只能向上访问,变量访问到 window 对象即被终止,作用域链向下访问变量是不被允许的. 简单的说,作 ...