ClickHouse 監控及備份 (二)Prometheus&Grafana 的安裝


0 Prometheus&Grafana 的安裝

Prometheus 下載地址:https://prometheus.io/download/
Grafana 下載地址:https://grafana.com/grafana/download

1 安裝 Prometheus

Prometheus 基於 Golang 編寫,編譯后的軟件包,不依賴於任何的第三方依賴。只需要下載對應平台的二進制包,解壓並且添加基本的配置即可正常啟動 Prometheus Server。
1.1 上傳安裝包
上傳 prometheus-2.26.0.linux-amd64.tar.gz 到虛擬機的/opt/software 目錄
1.2 解壓安裝包
(1)解壓到/opt/module 目錄下
[atguigu@hadoop1 software]$ tar -zxvf prometheus-2.26.0.linux-amd64.tar.gz -C /opt/module
(2)修改目錄名
[atguigu@hadoop1 ~] cd /opt/module
[atguigu@hadoop1 module] mv prometheus-2.26.0.linux-amd64 prometheus-2.26.0
1.3 修改配置文件 prometheus.yml
[atguigu@hadoop1 prometheus-2.26.0]$ vim prometheus.yml
在 scrape_configs 配置項下添加配置:
scrape_configs:
 
 - job_name: 'prometheus'
 static_configs:
 - targets: ['hadoop1:9090']
 #添加 ClickHouse 監控配置
 - job_name: clickhouse-1
 static_configs:
 - targets: ['hadoop1:9363']
配置說明:
1、global 配置塊:控制 Prometheus 服務器的全局配置
➢scrape_interval:配置拉取數據的時間間隔,默認為 1 分鍾。
➢evaluation_interval:規則驗證(生成 alert)的時間間隔,默認為 1 分鍾。
2、rule_files 配置塊:規則配置文件
3、scrape_configs 配置塊:配置采集目標相關, prometheus 監視的目標。Prometheus 自身
的運行信息可以通過 HTTP 訪問,所以 Prometheus 可以監控自己的運行數據。
➢job_name:監控作業的名稱
➢static_configs:表示靜態目標配置,就是固定從某個 target 拉取數據
➢targets : 指 定 監 控 的 目 標 , 其 實 就 是 從 哪 兒 拉 取 數 據 。 Prometheus 會 從
http://hadoop1:9090/metrics 上拉取數據。
Prometheus 是可以在運行時自動加載配置的。啟動時需要添加:--web.enable-lifecycle
1.4 啟動 Prometheus Server
[atguigu@hadoop1 prometheus-2.26.0]$ nohup ./prometheus --config.file=prometheus.yml > ./prometheus.log 2>&1 &
➢瀏覽器輸入:http://hadoop1:9090/
➢點擊 Status,選中 Targets:
prometheus 是 up 狀態,表示安裝啟動成功:

2 Grafana 安裝

2.1 上傳並解壓
(1)將 grafana-7.5.2.linux-amd64.tar.gz 上傳至/opt/software/目錄下,解壓: 
[atguigu@hadoop1 software]$ tar -zxvf grafana-7.5.2.linux-amd64.tar.gz -C /opt/module/
(2)更改名字: 
[atguigu@hadoop1 module]$ mv grafana-7.5.2.linux-amd64 grafana-7.5.2
2.2 啟動 Grafana
[atguigu@hadoop1 grafana-7.5.2]$ nohup ./bin/grafana-server web > ./grafana.log 2>&1 &
打開 web:http://hadoop1:3000,默認用戶名和密碼:admin
 

 


免責聲明!

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



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