mysql_exporter:用于收集MySQL性能信息蚓耽。監(jiān)聽端口:9104
項目地址:https://github.com/prometheus/mysqld_exporter
采集器位置: /usr/local/jiankong/mysqld_exporter
安裝采集器
cd /usr/local/jiankong/mysqld_exporter
tar zxvf mysqld_exporter-0.12.1.linux-amd64.tar.gz
mv mysqld_exporter-0.12.1.linux-amd64 mysqld_exporter
在mysql中創(chuàng)建一個賬戶賬戶用于搜集數(shù)據(jù)
grant process,replication client,select on *.* to 'exporter'@'%' identified by 'ex123456';
grant process,replication client,select on *.* to 'exporter'@'localhost' identified by 'ex123456';
flush privileges;
插件目錄下創(chuàng)建my.cnf
vim /usr/local/jiankong/mysqld_exporter/my.cnf
[client]
user=exporter
password=ex123456
加入系統(tǒng)服務
vim /usr/lib/systemd/system/mysqld_exporter.service
[Unit]
Description=mysqld_exporter
[Service]
ExecStart=/usr/local/jiankong/mysqld_exporter/mysqld_exporter --config.my-cnf=/usr/local/jiankong/mysqld_exporter/my.cnf
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
重載服務,啟動服務
systemctl daemon-reload
systemctl start mysqld_exporter
Prometheus加入監(jiān)控端
訪問一下接口http://192.168.1.112:9104/metrics
沒問題频祝。開始配置promethues
vim promethues.yml 加入被監(jiān)控主機采集接口
- job_name: 'mysql'
metrics_path: '/metrics'
static_configs:
- targets: ['192.168.1.112:9104']
重啟服務或者kill -HUP PID
Grafana添加儀表盤
MYSQL儀表盤推薦ID:7362