Prometheus 监控Mysql服务器及Grafana可视化、

mysql_exporter:用于收集MySQL性能信息。

  • 使用版本
  • mysqld_exporter 0.11.0
  • 官方地址
  • 使用文档:https://github.com/prometheus/mysqld_exporter
  • 图标模板:https://grafana.com/dashboards/7362
  • 下载地址:https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
  • 百度云:mysqld_exporter 0.11.0
  • 下载地址:https://pan.baidu.com/s/1JfjbK3uOMXObc7-F8h13Dw
  • 密码:dxsn

注:要求数据库mysql 5.5 以上版本。

 

安装mysql_exporter

1、下载到被监控端解压压缩包

tar zxvf mysqld_exporter-0.11.0.linux-amd64.tar.gz 

2、改名并移动到指定目录

mv mysqld_exporter-0.11.0.linux-amd64 /usr/local/mysql_exporter
cd /usr/local/mysql_exporter

3、登录mysql为exporter创建账号并授权

# 创建数据库用户。
mysql> CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'XXXXXXXX';
# 可查看主从运行情况查看线程,及所有数据库。
mysql> GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';

4、创建mysql配置文件、运行时可免密码连接数据库:vim /usr/local/mysql_exporter/.my.cnf

[client]
user=exporter
password=xiangsikai

5、启动exporter客户端

./mysqld_exporter --config.my-cnf=.my.cnf
常用参数:
# 选择采集innodb
--collect.info_schema.innodb_cmp
# innodb存储引擎状态
--collect.engine_innodb_status
# 指定配置文件
--config.my-cnf=".my.cnf"
启动常用参数

相关文章: