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
安裝教程鏈接>>https://www.jb51.net/article/204660.htm
5.1 添加promethus數(shù)據(jù)源 未完待續(xù)…
到此這篇關(guān)于Prometheus的安裝和配置教程詳解的文章就介紹到這了,更多相關(guān)Prometheus安裝和配置內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
標簽:鎮(zhèn)江 鶴崗 商丘 平頂山 綿陽 株洲 哈密 臺州
巨人網(wǎng)絡(luò)通訊聲明:本文標題《Prometheus的安裝和配置教程詳解》,本文關(guān)鍵詞 Prometheus,的,安裝,和,配置,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。