在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

相关文章:

  • 2022-01-16
  • 2022-12-23
  • 2022-03-07
  • 2022-12-23
  • 2021-08-25
  • 2021-12-17
  • 2021-07-06
  • 2021-07-05
猜你喜欢
  • 2021-06-18
  • 2022-12-23
  • 2021-10-02
  • 2021-06-27
  • 2021-05-27
  • 2022-02-22
相关资源
相似解决方案