掃二維碼與項目經(jīng)理溝通
我們在微信上24小時期待你的聲音
解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流
在Ubuntu 20.04上安裝Prometheus服務(wù)器的步驟如下:

1、更新系統(tǒng)軟件包列表
sudo apt update
2、安裝必要的依賴項
sudo apt install y wget tar
3、下載并解壓Prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.30.3/prometheus2.30.3.linuxamd64.tar.gz tar xzf prometheus2.30.3.linuxamd64.tar.gz cd prometheus2.30.3.linuxamd64
4、配置Prometheus
編輯prometheus.yml文件,設(shè)置監(jiān)控目標(biāo)和數(shù)據(jù)存儲位置。
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
job_name: 'prometheus'
static_configs:
targets: ['localhost:9090']
5、創(chuàng)建Prometheus服務(wù)文件
sudo nano /etc/systemd/system/prometheus.service
將以下內(nèi)容粘貼到文件中:
[Unit] Description=Prometheus Server Wants=networkonline.target After=networkonline.target StartLimitIntervalSec=0 StartLimitBurst=6 [Service] User=prometheus Group=prometheus Type=simple ExecStart=/usr/local/bin/prometheus config.file /path/to/your/prometheus.yml storage.tsdb.path /path/to/your/data web.console.libraries=/usr/share/prometheus/console_libraries web.console.templates=/usr/share/prometheus/consoles web.listenaddress=0.0.0.0:9090 storage.tsdb.minblockduration=1h storage.tsdb.maxblockduration=2h Restart=onfailure RestartSec=5s [Install] WantedBy=multiuser.target
將/path/to/your/prometheus.yml替換為實際的配置文件路徑,將/path/to/your/data替換為實際的數(shù)據(jù)存儲路徑。
6、重新加載systemd配置并啟動Prometheus服務(wù)
sudo systemctl daemonreload sudo systemctl start prometheus
7、檢查Prometheus服務(wù)狀態(tài)
sudo systemctl status prometheus
如果看到"Active: active (running)",則表示Prometheus已成功安裝并運行。

我們在微信上24小時期待你的聲音
解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流