Prometheus+Grafana学习(三) 监控windows下的mysql

一、安装Grafana和Prometheus

略,参考:https://blog.csdn.net/u011943534/article/details/122452337

二、安装Mysqld_exporter

MySQL版本需要在5.5以上。
Mysqld_exporter用于收集MySQL性能信息。
官方源码和文档地址:https://github.com/prometheus/mysqld_exporter
使用版本:0.13.0,在github的tag中下载。

1.下载

下载地址:https://github.com/prometheus/mysqld_exporter/releases/download/v0.13.0/mysqld_exporter-0.13.0.windows-amd64.zip

2.安装windows版mysqld_exporter

前提是机器上已经安装了MySQL,安装过程与linux下大概一致。

(1)解压
tar zvxf mysqld_exporter-0.13.0.linux-amd64.tar.gz

(2)登录mysql为exporter创建账号并授权
创建数据库用户
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'exporter';
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
ALTER USER exporter@localhost IDENTIFIED WITH mysql_native_password BY 'exporter';
flush privileges;

(3)创建MySQL配置文件exporter.ini,配置免密码连接数据库
编辑内容:
[client]
user=exporter
password=exporter

(4)启动exporter客户端
mysqld_exporter.exe --config.my-cnf=exporter.ini
其他参数
  # 选择采集innodb
--collect.info_schema.innodb_cmp
# innodb存储引擎状态
--collect.engine_innodb_status
# 指定配置文件
--config.my-cnf=".my.cnf"

3.测试使用mysqld_exporter

访问: http://IP:9104/metrics
在这里插入图片描述

三、配置Prometheus

1.修改配置文件

在之前配置的mysql8.x中添加windows下的mysqld_exporter地址192.168.100.88:9104。

cat prometheus.yaml
添加一个job_name:mysql8.x,targets的IP配置为上一步装好的mysqld_exporter
如下:

scrape_configs:
# 可随意指定
- job_name: 'spring'
  # 多久采集一次数据
  scrape_interval: 15s
  # 采集时的超时时间
  scrape_timeout: 10s
  # 采集的路径
  metrics_path: '/demo/actuator/prometheus'
  # 采集服务的地址,设置成Springboot应用所在服务器的具体地址
  static_configs:
  - targets: ['192.168.100.88:7901']
- job_name: 'mysql8.x'
  #静态添加node
  static_configs:
  - targets: ['172.16.10.169:9104', '192.168.100.88:9104']

2.重启prometheus

docker ps

在这里插入图片描述

docker restart 78738bfedc5b

3.查看prometheus

访问http://IP:9090/targets,查看targets,发现mysql已经加入
在这里插入图片描述
随便测试一个指标:

go_memstats_heap_alloc_bytes

在这里插入图片描述

三、配置Grafana

使用linux的mysql配置时导入的JSON就可以。
刷新页面,会发现多了windows下的mysql
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值