1.安装mysql_exporter
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
解压
tar zxvf mysqld_exporter-0.12.1.linux-amd64.tar.gz
mv mysqld_exporter-0.12.1.linux-amd64 /usr/local/mysql_exporter
cd /usr/local/mysql_exporter
2.在mysql中创建exporter用户并赋予权限
CREATE USER 'exporter'@'localhost' IDENTIFIED BY '123456';
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
flush privileges;
3.创建配置文件
vim /usr/local/mysql_exporter/.my.cnf
[client]
user=exporter
password=000000
4.启动
nohup ./mysqld_exporter --config.my-cnf=.my.cnf &
5.测试访问ip:9104
6.Prometheus添加节点
- job_name: 'Mysql'
static_configs:
- targets:
- '10.7.110.221:9104'
7.Grafana添加模板7362后查看监控