mysqld_exporter:https://github.com/prometheus/mysqld_exporter

Supported versions:

  • MySQL >= 5.6.
  • MariaDB >= 10.1

数据库授权

1
2
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'XXXXXXXX' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';

修改my.cnf配置:

1
2
3
[client] 
user=exporter
password=XXXXXXXX

重启MySQL

1
systemctl restart mysqld

下载

地址:https://github.com/prometheus/mysqld_exporter/releases

1
2
3
4
mkdir -p /monitor/exporter
cd /monitor/exporter
VER=0.XX.X # 选择需要安装的版本号
wget "https://github.com/prometheus/mysqld_exporter/releases/download/v${VER}/mysqld_exporter-${VER}.linux-amd64.tar.gz" -C mysqld_exporter

启动

1
2
cd mysqld_exporter
nohup ./mysqld_exporter --config.my-cnf=/etc/my.cnf &