首页 > 数据库技术 > 详细

Prometheus监控MySQL

时间:2020-07-02 09:21:37      阅读:64      评论:0      收藏:0      [点我收藏+]

在k8s的master节点安装mysql_exporter组件

1、解压

tar -xvf mysqld_exporter-0.10.0.linux-amd64.tar.gz

 2、拷贝二进制文件到/usr/local/bin目录下

cd mysqld_exporter-0.10.0.linux-amd64
cp -ar mysqld_exporter /usr/local/bin/

 3、对mysqld_exporter授予可执行权限

chmod +x /usr/local/bin/mysqld_exporter

 陆mysql为mysql_exporter创建账号并授权

# 创建数据库用户。

mysql> CREATE USER ‘mysql_exporter‘@‘localhost‘ IDENTIFIED BY ‘Abcdef123!.‘;

# 对mysql_exporter用户授权 

mysql> GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO ‘mysql_exporter‘@‘localhost‘;

 创建mysql配置文件、运行时可免密码连接数据库

cd mysqld_exporter-0.10.0.linux-amd64

cat my.cnf

显示如下:

[client]
user=mysql_exporter
password=Abcdef123!.

 启动mysql_exporter客户端

nohup ./mysqld_exporter --config.my-cnf=./my.cnf &

 mysqld_exporter的监听端口是9104

修改prometheus-cfg.yaml文件,添加如下

- job_name: ‘mysql‘    
  static_configs:    
  - targets: [‘192.168.124.16:9104‘]

 更新prometheus的yaml文件,使配置生效

kubectl delete -f prometheus-cfg.yaml
kubectl apply -f prometheus-cfg.yaml
kubectl delete -f prometheus-deploy.yaml
kubectl apply -f prometheus-deploy.yaml

 https://mp.weixin.qq.com/s/7wL9zePLAo99b1J0PYxkaQ

Prometheus监控MySQL

原文:https://www.cnblogs.com/zjz20/p/13222776.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!