最新原文:https://www.cnblogs.com/uncleyong/p/13192456.html

架构

在需要监控的mysql上安装 node_exporter和 mysqld_exporter

架构示意图:https://processon.com/diagraming/6028831e079129342249700e

Prometheus环境搭建系列(二):监控mysql服务器(mysqld_exporter)

 

下载

https://github.com/prometheus/mysqld_exporter/releases

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 -C /usr/local/

Prometheus环境搭建系列(二):监控mysql服务器(mysqld_exporter)

修改配置文件

vim .my.cnf

Prometheus环境搭建系列(二):监控mysql服务器(mysqld_exporter)

添加获取mysql监控数据的账号,如果不写端口,默认为3306

(根据自己安装的mysql实际情况填写)

[client]
user=root
password=mysql123
port=3206

 

也可以另外创建用户并授权

GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'mysql_exporter'@'localhost' identified by '123456';
GRANT SELECT ON performance_schema.* TO 'mysql_exporter'@'localhost';
flush privileges;

  

启动服务

./mysqld_exporter --config.my-cnf=".my.cnf"

Prometheus环境搭建系列(二):监控mysql服务器(mysqld_exporter)

Prometheus环境搭建系列(二):监控mysql服务器(mysqld_exporter)

 

验证:http://IP:9104/metrics

搜索:max_connections

Prometheus环境搭建系列(二):监控mysql服务器(mysqld_exporter)

 

在prometheus.yml中加入job

  - job_name: 'mysql'
    static_configs:
    - targets: ['localhost:9104']

 

重启prometheus:nohup /usr/local/prometheus-2.19.1.linux-amd64/prometheus --config.file=/usr/local/prometheus-2.19.1.linux-amd64/prometheus.yml &

http://ip:9090/targets

mysql的状态变成up了

Prometheus环境搭建系列(二):监控mysql服务器(mysqld_exporter)

 

Prometheus环境搭建系列(二):监控mysql服务器(mysqld_exporter)

 

grafana导入模板 

https://grafana.com/grafana/dashboards/7362

导入

Prometheus环境搭建系列(二):监控mysql服务器(mysqld_exporter)

 

Prometheus环境搭建系列(二):监控mysql服务器(mysqld_exporter)

 

效果(报告含义不清楚的可以咨询作者)

Prometheus环境搭建系列(二):监控mysql服务器(mysqld_exporter)

 

 

最新原文:https://www.cnblogs.com/uncleyong/p/13192456.html

 

相关文章:

  • 2021-12-13
  • 2021-07-06
  • 2022-03-09
  • 2021-05-21
  • 2021-06-19
  • 2021-11-19
  • 2021-08-19
  • 2021-09-14
猜你喜欢
  • 2021-07-08
  • 2022-12-23
  • 2022-01-17
  • 2021-08-28
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案