Prometheus安裝部署和監控MySQL,並在grafana上展示


Prometheus的安裝還是比較簡單的

下載地址如下

https://prometheus.io/download/

 解壓,修改配置,運行。默認監聽9090端口

[root@localhost ~]# tar -xvf prometheus-2.14.0.linux-amd64.tar.gz
[root@localhost ~]# cd prometheus-2.14.0.linux-amd64
[root@localhost prometheus-2.14.0.linux-amd64]# cat prometheus.yml |grep 9090    #因為我需要在外部訪問,所以把以下部分的localhost修改為服務器IP
    - targets: ['192.168.100.128:9090']
[root@localhost prometheus-2.14.0.linux-amd64]# ./prometheus

訪問WEB

 

查看能否正常監控到數據。state為up則為監控正常

 下面我們嘗試監控MySQL

部署MySQL

部署安裝配置MySQL的步驟就濾過了。都是老生常談。數據庫賬號密碼root/123456

下載mysqld_exporter

https://prometheus.io/download/#mysqld_exporter

解壓,配置連接MySQL的信息,運行。默認監聽9104端口

[root@localhost ~]# tar -xvf mysqld_exporter-0.ar.gz
[root@localhost ~]# cat /root/.my.cnf 
[client]
host=127.0.0.1
user=root
password=123456
[root@localhost ~]# cd mysqld_exporter-0.12.1.linux-amd64
[root@localhost mysqld_exporter-0.12.1.linux-amd64]#mysqld_exporter

訪問9104端口,看能否正常訪問到

 

 現在我們讓Prometheus監控MySQL。只需修改yml文件,把9090修改為9104端口即可

[root@localhost prometheus-2.14.0.linux-amd64]# grep 9104 prometheus.yml 
    - targets: ['192.168.100.128:9104']
[root@localhost prometheus-2.14.0.linux-amd64]# 

修改以上配置后重啟Prometheus。頁面刷新后自動修改為監控9104端口了

 配置grafana

安裝並啟動grafana。默認監聽3000端口

wget https://dl.grafana.com/oss/release/grafana-6.4.4-1.x86_64.rpm
yum install grafana-6.4.4-1.x86_64.rpm
systemctl start grafana-server

配置grafana顯示Prometheus數據

 

 

 

 

 

 

 

 圖形顯示

下載並導入mysql的dashboard

下載鏈接:

https://github.com/percona/grafana-dashboards

將dashboards里的MySQL_Overview.json導入grafana

 

 上傳文件

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM