Prometheus監(jiān)控Mysql服務(wù)器

mysql_exporter:用于收集MySQL性能信息。監(jiān)聽端口:9104
項(xiàng)目地址: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)建一個(gè)賬戶賬戶用于搜集數(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)服務(wù)

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

重載服務(wù),啟動(dòng)服務(wù)
systemctl daemon-reload
systemctl start mysqld_exporter


image.png

Prometheus加入監(jiān)控端

訪問一下接口http://192.168.1.112:9104/metrics

image.png

沒問題。開始配置promethues
vim promethues.yml 加入被監(jiān)控主機(jī)采集接口

- job_name: 'mysql'
    metrics_path: '/metrics'
    static_configs:
    - targets: ['192.168.1.112:9104']

重啟服務(wù)或者kill -HUP PID

image.png

Grafana添加儀表盤

MYSQL儀表盤推薦ID:7362


image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容