你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

为适用于 SAP 解决方案的 Azure Monitor 配置 Linux 提供程序

本操作指南介绍如何为适用于 SAP 解决方案资源的 Azure Monitor 创建 Linux OS 提供程序。

先决条件

在 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 Monitor。
  3. 选择创建,创建新的 Azure Monitor for SAP 解决方案资源。
  4. 选择“添加提供程序”。
  5. 为新提供程序配置以下设置:
    1. 对于“类型”,选择“OS(Linux)” 。
    2. 对于 Name,请输入提供程序的唯一名称。
    3. (可选)选择“ 启用安全通信”,选择证书类型。
    4. 对于 节点导出终结点,请输入 http://IP:9100/metrics 使用默认端口 9100。 如果使用自定义端口,请输入 http://IP:PORT/metrics。 替换为 IP Linux 主机的 IP 地址和 PORT 自定义端口号。
    5. 对于 IP 地址,请使用 Linux 主机的专用 IP 地址。 确保主机和 Azure Monitor for SAP 解决方案资源位于同一虚拟网络中。
  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 Monitor 时提供的子网访问。

建议

使用此建议进行故障排除

启用节点导出程序

  1. 运行命令 nohup ./node_exporter & 以启用 node_exporter
  2. 从 Linux 计算机命令行添加 nohup& 添加到上述命令 node_exporter 。 如果未包含它们, node_exporter 请在命令行关闭时停止。

后续步骤