遇一山,过一山,处处有风景;只要勇敢向前,一路尽是繁花盛开。 | (点击查看→)【测试干货】python/java自动化、持续集成、性能、测开、简历、笔试面试等

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

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

架构

在需要监控的mysql上安装 node_exporter和 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/

修改配置文件

cd /usr/local/mysqld_exporter-0.12.1.linux-amd64/

vim .my.cnf

添加获取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"

 

验证:http://IP:9104

搜索:max_connections

 

在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 &

或者:systemctl restart prometheus

    systemctl status prometheus

http://ip:9090

 

mysql的状态变成up了

 

mysql_global_variables_max_connections

 

grafana导入模板 

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

导入

 

 

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

 

 

原文会持续更新,原文地址:https://www.cnblogs.com/uncleyong/p/13192456.html

 

posted @ 2021-05-14 21:26  全栈测试笔记  阅读(528)  评论(0编辑  收藏  举报
浏览器标题切换
浏览器标题切换end