在上一篇中介绍过怎么安装grafana+prometheus,这篇介绍在mysql机器上安装mysql-exporter。
1.下载mysqld_exporter-0.15.1.windows-amd64.zip
2.由于监控需要进程相关监控权限,需要创建用户并分配权限
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'your_password';
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
FLUSH PRIVILEGES;
3.在mysql机器解压mysqld_exporter-0.15.1.windows-amd64.zip,创建my.cnf文件,写入
[client]
host = 127.0.0.1
port = 3306
user = exporter
password = 你的密码
4.编写执行启动脚本mysql-exporter-start.bat,和my.cnf、mysqld_exporter.exe在同一目录下
mysqld_exporter.exe --config.my-cnf=my.cnf