Prometheus的安裝和配置教程詳解
1. 從官網(wǎng)選擇Prometheus版本進行下載
官網(wǎng)地址>> https://github.com/prometheus/prometheus/releases/
2. 實驗安排
在主機192.168.153.137上安裝prometheus監(jiān)控192.168.153.138上的mysql服務(wù)和主機狀態(tài)
3. 上傳軟件包到137服務(wù)器并配置
3.1 將軟件包解壓到 /usr/local 目錄下
tar xzf prometheus-2.24.1.linux-amd64.tar.gz -C /usr/local/
3.2 給目錄創(chuàng)建軟鏈接
ln -s /usr/local/prometheus-2.24.1.linux-amd64/ /usr/local/prometheus
3.3 切換到目錄下
cd /usr/local/prometheus
3.4 修改配置文件 prometheus.yml
,配置要監(jiān)控的項
scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['localhost:9090'] #監(jiān)控Linux主機狀態(tài) - job_name: 'linux' static_configs: - targets: ['192.168.153.138:9100'] #監(jiān)控mysql服務(wù)狀態(tài) - job_name: 'mysql' static_configs: - targets: ['192.168.153.138:9104']
3.5 啟動promethus服務(wù)
./prometheus --config.file=prometheus.yml
3.6 瀏覽器輸入 IP:9090
查看
在Status->Targets
頁面下,我們可以看到我們配置的兩個Target,它們的State為DOWN。
4. 配置138主機 4.1 下載exporter
下載地址>> https://github.com/prometheus/node_exporter/releases
4.2 將軟件包解壓到 /usr/local 目錄下
tar xzf node_exporter-1.0.1.linux-amd64.tar.gz -C /usr/local/
4.3 啟動exporter
nohup /usr/local/node_exporter-1.0.1.linux-amd64/node_exporter &
4.4 下載mysqld_exporter
下載地址>> https://github.com/prometheus/mysqld_exporter/releases
4.5 將軟件包解壓到 /usr/local 目錄下
tar xzf mysqld_exporter-0.12.1.linux-amd64.tar.gz -C /usr/local/
4.6 數(shù)據(jù)庫給mysqld_exporter授權(quán)
[root@host-138 ~]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. MariaDB [(none)]> GRANT REPLICATION CLIENT,PROCESS ON *.* TO 'mysql_monitor'@'localhost' identified by 'mysql_monitor'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT SELECT ON *.* TO 'mysql_monitor'@'localhost'; Query OK, 0 rows affected (0.00 sec)
4.7 創(chuàng)建 .my.cnf
配置文件
vim /usr/local/mysqld_exporter-0.12.1.linux-amd64/.my.cnf
內(nèi)容為:
[client] user=mysql_monitor password=mysql_monitor
4.8 運行mysqld_exporter服務(wù)
nohup /usr/local/mysqld_exporter-0.12.1.linux-amd64/mysqld_exporter --config.my-cnf="/usr/local/mysqld_exporter-0.12.1.linux-amd64/.my.cnf" &
5. 在promethus頁面刷新Status->Targets頁面,可以看到配置的兩個Target的State為UP:
5. 在137主機上安裝部署grafana
安裝教程鏈接>>http://www.dbjr.com.cn/article/204660.htm
5.1 添加promethus數(shù)據(jù)源 未完待續(xù)…
到此這篇關(guān)于Prometheus的安裝和配置教程詳解的文章就介紹到這了,更多相關(guān)Prometheus安裝和配置內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
詳解DES&3DES算法的原理以及C#和JS的實現(xiàn)
DES?全稱為?Data?Encryption?Standard,即數(shù)據(jù)加密標(biāo)準(zhǔn),是一種使用密鑰加密的塊算法。3DES?算法通過對?DES?算法進行改進,增加?DES?的密鑰長度來避免類似的攻擊。本文就來聊聊它們的原理與實現(xiàn)吧2023-03-03刪除SVN三種方法delSvn(windows+linux)
今天想清除目錄下的SVN信息,在網(wǎng)上找了找,說是有三種方法2012-03-03Git基礎(chǔ)之git與SVN版本控制優(yōu)缺點區(qū)別分析
這篇文章主要為大家介紹了Git基礎(chǔ)之git與SVN優(yōu)缺點及區(qū)別分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-04-04