設定適用於 SAP 解決方案的 Azure 監視器的 Linux 提供者

在本操作指南中,您將瞭解如何為適用於 SAP 解決方案資源的 Azure 監視器建立 Linux OS 提供者。

必要條件

  • Azure 訂用帳戶。
  • 現有的 Azure Monitor for SAP Solutions 資源。 若要建立適用於 SAP 的 Azure 監視器解決方案資源,請參閱適用於 PowerShell 的 Azure 入口網站 快速入門或快速入門。
  • 您想要監視的每個 SAP 主機中,安裝節點匯出工具最新版本 ,無論是 BareMetal 或 Azure 虛擬機(VM)。 如需詳細資訊,請參閱節點導出工具 GitHub 存放
  • 節點導出工具會使用預設埠 9100 來公開計量。 如果您想要使用自定義埠,請務必在防火牆中開啟埠,並在建立提供者時使用相同的埠。
  • 將針對節點導出工具設定的預設埠 9100 或自定義埠,應在 Linux 主機上開啟並接聽。

若要在 Linux 上安裝節點匯出工具:

以滑鼠右鍵按兩下 Linux https://prometheus.io/download/#node_exporter 的相關節點匯出工具版本,並複製將在下列命令中使用的連結位址。 例如 - https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz

  1. 變更為您要安裝節點匯出工具的目錄。

  2. 執行 wget https://github.com/prometheus/node_exporter/releases/download/v<xxx>/node_exporter-<xxx>.linux-amd64.tar.gz。 將取代 xxx 為版本號碼。

  3. tar xvfz node_exporter-<xxx>.linux-amd64.tar.gz執行

  4. cd node_exporter-<xxx>linux-amd64執行

  5. 執行 ./node_exporter

  6. ./node_exporter --web.listen-address=":9100" &執行

  7. 節點匯出工具現在會開始收集數據。 您可以在 匯出數據 http://<ip>:9100/metrics

設定節點匯出工具的腳本

# To get the latest node exporter version from: https://prometheus.io/download/#node_exporter
# Right click on the linux node exporter version and copy the link address which will be used in the below command. For example - https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz
# Change to the directory where you want to install the node exporter.

wget https://github.com/prometheus/node_exporter/releases/download/v<xxx>/node_exporter-<xxx>.linux-amd64.tar.gz
tar xzvf node_exporter-<xxx>.linux-amd64.tar.gz
cd node_exporter-<xxx>linux-amd64
nohup ./node_exporter --web.listen-address=":9100" &

設定 systemctl 服務以在虛擬機重新啟動時啟動節點導出工具

  1. 如果目標 VM 重新啟動或停止,節點匯出工具服務就會停止。 必須再次手動啟動,才能繼續監視。

  2. 執行下列命令,讓節點匯出工具以服務身分執行。

    注意

    將此值 xxxx 取代為節點匯出工具的版本。 例如: 1.6.1

    # Change to the directory where node exporter bits are downloaded and copy the node_exporter folder to path /usr/bin
    sudo mv node_exporter-<xxxx>.linux-amd64 /usr/bin
    # Create a node_exporter as a service file under etc/systemd/system
    sudo tee /etc/systemd/system/node_exporter.service<<EOF
    [Unit]
    Description=Node Exporter
    After=network.target
    [Service]
    Type=simple
    Restart=always
    ExecStart=/usr/bin/node_exporter-<xxxx>.linux-amd64/node_exporter $ARGS
    ExecReload=/bin/kill -HUP $MAINPID
    [Install]
    WantedBy=multi-user.target
    EOF
    # Reload the system daemon and start the node exporter service.
    
    sudo systemctl daemon-reload
    sudo systemctl start node_exporter
    sudo systemctl enable node_exporter
    
    # Check the status of node exporter if it is running in active(running) state.
    sudo systemctl status node_exporter
    
    # To test the node exporter running as a service
    # NOTE - Downtime impacts the Business application running on VM
    # Crash/Re-start the Virtual Machine, login back into VM and check node exporter status to be active(running)
    sudo systemctl status node_exporter
    

啟用安全通訊的必要條件

若要啟用 TLS 1.2 或更高版本,請遵循本文中的步驟。

建立 Linux OS 提供者

  1. 登入 Azure 入口網站
  2. 移至適用於 SAP 的 Azure 監視器解決方案。
  3. 選取 [建立 ] 以建立新的適用於 SAP 解決方案資源的 Azure 監視器。
  4. 選取 [新增提供者]。
  5. 為新的提供者設定下列設定:
    1. 針對 [ 類型],選取 [OS(Linux)]。
    2. 針對 [ 名稱],輸入提供者的唯一名稱。
    3. (選擇性)選取 [ 啟用安全通訊],選擇憑證類型。
    4. 針對 [ 節點導出工具端點],輸入 http://IP:9100/metrics 是否使用預設埠 9100。 如果使用自訂埠,請輸入 http://IP:PORT/metrics。 取代為 Linux 主機的 IP 位址,並以PORT自訂埠號碼取代 IP
    5. 針對IP位址,請使用Linux主機的私人IP位址。 請確定適用於 SAP 解決方案的主機和 Azure 監視器資源位於相同的虛擬網路中。
  6. 在 Linux 主機上開啟防火牆埠 9100。
    1. 如果您使用 firewall-cmd,請執行 _firewall-cmd_ _--permanent_ _--add-port=9100/tcp_ ,然後執行 _firewall-cmd_ _--reload_
    2. 如果您使用 ufw,請執行 _ufw_ _allow_ _9100/tcp_ ,然後執行 _ufw_ _reload_
  7. 如果 Linux 主機是 Azure VM,請確定所有適用的網路安全組都允許來自 VirtualNetwork 的埠 9100 作為來源的輸入流量。
  8. 選取 [新增提供者 ] 以儲存變更。
  9. 視需要繼續新增更多提供者。
  10. 選取 [檢閱 + 建立] 檢閱設定。
  11. 選取 [建立 ] 以完成資源建立。

疑難排解

使用這些步驟來解決常見的錯誤。

無法連線到 Prometheus 端點

當提供者設定驗證工作失敗時,程式代碼 PrometheusURLConnectionFailure為 :

  1. 檢查針對節點匯出工具所設定的預設埠 9100 或自定義埠是否已開啟,並在 Linux 主機上接聽。
  2. 嘗試重新啟動節點匯出代理程式:
    1. 移至您安裝節點匯出工具的資料夾(檔案名類似 node_exporter-<xxxx>-amd64)。
    2. 執行 ./node_exporter
    3. 執行 nohup ./node_exporter & 命令以啟用node_exporter。 將 nohup 和 和 新增至上述命令,會將node_exporter與 linux 計算機命令行分離。 如果未包含node_exporter命令行關閉時會停止。
  3. 確認 Prometheus 端點可從您在建立適用於 SAP 解決方案資源的 Azure 監視器時所提供的子網連線。

建議

使用此建議進行疑難解答

啟用節點匯出工具

  1. nohup ./node_exporter &執行 命令以開啟 node_exporter
  2. 將和 新增nohup&至上述命令會node_exporter與Linux電腦命令行分離。 如果未包含它們, node_exporter 會在命令行關閉時停止。

下一步