亚欧色一区w666天堂,色情一区二区三区免费看,少妇特黄A片一区二区三区,亚洲人成网站999久久久综合,国产av熟女一区二区三区

  • 發布文章
  • 消息中心
點贊
收藏
評論
分享
原創

prometheus生產環境落地實踐一:部署prometheus

2024-07-01 03:27:02
30
0

1. 監控軟件選型

市面上有不少監控軟件,關于prometheus與其它監控軟件的區別網上有很多資料,這里不再贅述,只簡單說一下當時為什么選擇了prometheus:

  • prometheus是開源軟件,免費使用。
  • prometheus社區生態比較好,在國內應用廣泛,網上有很多資料。
  • prometheus擁有眾多exporter,基本覆蓋公司內使用的數據庫與中間件產品。
  • 公司有把業務系統遷移到k8s上的打算,prometheus天然適配k8s。

2. prometheus主機資源選擇

prometheus需要的主機規格與較多因素有關,如采集樣本數,采集頻率、數據保留時間等,要根據實際需求進行評估。磁盤建議選擇高IO的SSD盤,我們初期選用了IO較低的機械盤,結果導致監控數據查詢很慢,grafana上的圖要很久才能刷新出來。

3. prometheus安裝包下載

  1. 官網://prometheus.io/download/
  2. github://github.com/prometheus/prometheus

4. 部署prometheus

  1. 解壓安裝包:

    tar -xvf prometheus-2.xx.x.linux-amd64.tar.gz
    mv prometheus-2.xx.x.linux-amd64 /app/prometheus
    
  2. prometheus支持的啟動參數可以通過 ./prometheus --help獲取,我們主要關注以下幾個啟動參數:

    # 指定prometheus配置文件:
    --config.file
    
    # tsdb數據存儲路徑:
    --storage.tsdb.path
    
    # tsdb數據存儲時間:
    --storage.tsdb.retention.time
    
    # tsdb數據存儲大小:
    --storage.tsdb.retention.size
    
    # prometheus的web地址
    --web.listen-address
    
    # 管理控制操作啟用API端點
    --web.enable-admin-api
    
    # 啟用是否通過HTTP請求重新加載
    --web.enable-lifecycle
    
    # 日志等級
    --log.level=info
    
  3. promtool提供檢查配置文件的功能

    ./promtool check config prometheus.yml
    
  4. 另外prometheus還提供了reload接口,使我們在更改配置文件后不必重啟prometheus就可將更改內容應用。

    curl -X POST //127.0.0.1:9090/-/reload
    
  5. 基于以上知識點,我們創建以下prometheus.service文件

    vi /usr/lib/systemd/system/prometheus.service
    
    
    [Unit]
    Description=Prometheus
    After=network.target
    
    [Service]
    Type=simple
    User=root
    ExecStartPre=/app/prometheus/promtool check config /app/prometheus/prometheus.yml
    ExecStart=/app/prometheus/prometheus \
    --config.file=/app/prometheus/prometheus.yml \
    --storage.tsdb.path=/app/prometheus/data \
    --storage.tsdb.retention.time=30d \
    --web.listen-address=0.0.0.0:9090 \
    --web.enable-admin-api \
    --web.enable-lifecycle \
    --log.level=info
    ExecReload=/bin/curl -X POST //127.0.0.1:9090/-/reload
    TimeoutStopSec=20s
    Restart=on-failure
    
    [Install]
    WantedBy=multi-user.target
    
  6. 如果公司禁止使用root用戶啟動應用,那這里要把User改成其它用戶,如prometheus普通用戶,并且要將相關目錄授權給prometheus普通用戶。

    chown -R prometheus:prometheus /app/prometheus/
    
  7. 啟動prometheus服務

    systemctl daemon-reload
    systemctl enable --now prometheus.service
    systemctl status prometheus.service
    
  8. 如果prometheus服務啟動失敗,可以使用以下命令檢查失敗原因:

    journalctl -u prometheus.service
    
  9. prometheus服務正常啟動后,我們就可以通過瀏覽器訪問prometheus了。

    //IP:9090/
    
0條評論
0 / 1000
范****強
1文章數
0粉絲數
范****強
1 文章 | 0 粉絲
范****強
1文章數
0粉絲數
范****強
1 文章 | 0 粉絲
原創

prometheus生產環境落地實踐一:部署prometheus

2024-07-01 03:27:02
30
0

1. 監控軟件選型

市面上有不少監控軟件,關于prometheus與其它監控軟件的區別網上有很多資料,這里不再贅述,只簡單說一下當時為什么選擇了prometheus:

  • prometheus是開源軟件,免費使用。
  • prometheus社區生態比較好,在國內應用廣泛,網上有很多資料。
  • prometheus擁有眾多exporter,基本覆蓋公司內使用的數據庫與中間件產品。
  • 公司有把業務系統遷移到k8s上的打算,prometheus天然適配k8s。

2. prometheus主機資源選擇

prometheus需要的主機規格與較多因素有關,如采集樣本數,采集頻率、數據保留時間等,要根據實際需求進行評估。磁盤建議選擇高IO的SSD盤,我們初期選用了IO較低的機械盤,結果導致監控數據查詢很慢,grafana上的圖要很久才能刷新出來。

3. prometheus安裝包下載

  1. 官網://prometheus.io/download/
  2. github://github.com/prometheus/prometheus

4. 部署prometheus

  1. 解壓安裝包:

    tar -xvf prometheus-2.xx.x.linux-amd64.tar.gz
    mv prometheus-2.xx.x.linux-amd64 /app/prometheus
    
  2. prometheus支持的啟動參數可以通過 ./prometheus --help獲取,我們主要關注以下幾個啟動參數:

    # 指定prometheus配置文件:
    --config.file
    
    # tsdb數據存儲路徑:
    --storage.tsdb.path
    
    # tsdb數據存儲時間:
    --storage.tsdb.retention.time
    
    # tsdb數據存儲大小:
    --storage.tsdb.retention.size
    
    # prometheus的web地址
    --web.listen-address
    
    # 管理控制操作啟用API端點
    --web.enable-admin-api
    
    # 啟用是否通過HTTP請求重新加載
    --web.enable-lifecycle
    
    # 日志等級
    --log.level=info
    
  3. promtool提供檢查配置文件的功能

    ./promtool check config prometheus.yml
    
  4. 另外prometheus還提供了reload接口,使我們在更改配置文件后不必重啟prometheus就可將更改內容應用。

    curl -X POST //127.0.0.1:9090/-/reload
    
  5. 基于以上知識點,我們創建以下prometheus.service文件

    vi /usr/lib/systemd/system/prometheus.service
    
    
    [Unit]
    Description=Prometheus
    After=network.target
    
    [Service]
    Type=simple
    User=root
    ExecStartPre=/app/prometheus/promtool check config /app/prometheus/prometheus.yml
    ExecStart=/app/prometheus/prometheus \
    --config.file=/app/prometheus/prometheus.yml \
    --storage.tsdb.path=/app/prometheus/data \
    --storage.tsdb.retention.time=30d \
    --web.listen-address=0.0.0.0:9090 \
    --web.enable-admin-api \
    --web.enable-lifecycle \
    --log.level=info
    ExecReload=/bin/curl -X POST //127.0.0.1:9090/-/reload
    TimeoutStopSec=20s
    Restart=on-failure
    
    [Install]
    WantedBy=multi-user.target
    
  6. 如果公司禁止使用root用戶啟動應用,那這里要把User改成其它用戶,如prometheus普通用戶,并且要將相關目錄授權給prometheus普通用戶。

    chown -R prometheus:prometheus /app/prometheus/
    
  7. 啟動prometheus服務

    systemctl daemon-reload
    systemctl enable --now prometheus.service
    systemctl status prometheus.service
    
  8. 如果prometheus服務啟動失敗,可以使用以下命令檢查失敗原因:

    journalctl -u prometheus.service
    
  9. prometheus服務正常啟動后,我們就可以通過瀏覽器訪問prometheus了。

    //IP:9090/
    
文章來自個人專欄
文章 | 訂閱
0條評論
0 / 1000
請輸入你的評論
0
0