你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
为适用于 SAP 解决方案的 Azure Monitor 配置 Linux 提供程序
本操作指南介绍如何为适用于 SAP 解决方案资源的 Azure Monitor 创建 Linux OS 提供程序。
先决条件
- Azure 订阅。
- 现有 Azure Monitor for SAP 解决方案资源。 如需创建 Azure Monitor for SAP Solutions 资源,请参阅 Azure 门户快速入门或 PowerShell 快速入门。
- 在 要监视的每个 SAP 主机(BareMetal 或 Azure 虚拟机)中安装节点导出程序最新版本 。 有关详细信息,请参阅节点导出程序 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
更改为要安装节点导出程序所在的目录。
运行
wget https://github.com/prometheus/node_exporter/releases/download/v<xxx>/node_exporter-<xxx>.linux-amd64.tar.gz
。 将xxx
替换为版本号。tar xvfz node_exporter-<xxx>.linux-amd64.tar.gz
运行cd node_exporter-<xxx>linux-amd64
运行运行
./node_exporter
。./node_exporter --web.listen-address=":9100" &
运行节点导出程序现在开始收集数据。 可以在
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 服务以在虚拟机重启时启动节点导出程序
如果目标 VM 重新启动或停止,则节点导出程序服务将停止。 必须再次手动启动它才能继续监视。
运行以下命令,使节点导出程序能够作为服务运行。
注意
将此
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 提供程序
- 登录 Azure 门户。
- 转到适用于 SAP 解决方案的 Azure Monitor。
- 选择创建,创建新的 Azure Monitor for SAP 解决方案资源。
- 选择“添加提供程序”。
- 为新提供程序配置以下设置:
- 对于“类型”,选择“OS(Linux)” 。
- 对于 Name,请输入提供程序的唯一名称。
- (可选)选择“ 启用安全通信”,选择证书类型。
- 对于 节点导出终结点,请输入
http://IP:9100/metrics
使用默认端口 9100。 如果使用自定义端口,请输入http://IP:PORT/metrics
。 替换为IP
Linux 主机的 IP 地址和PORT
自定义端口号。 - 对于 IP 地址,请使用 Linux 主机的专用 IP 地址。 确保主机和 Azure Monitor for SAP 解决方案资源位于同一虚拟网络中。
- 在 Linux 主机上打开防火墙端口 9100。
- 如果使用
firewall-cmd
,请运行_firewall-cmd_ _--permanent_ _--add-port=9100/tcp_
并运行_firewall-cmd_ _--reload_
。 - 如果使用
ufw
,请运行_ufw_ _allow_ _9100/tcp_
并运行_ufw_ _reload_
。
- 如果使用
- 如果 Linux 主机是 Azure VM,请确保所有适用的网络安全组都允许从 VirtualNetwork 端口 9100 作为源的入站流量。
- 选择“添加提供程序”,保存所做更改。
- 根据需要继续添加更多提供程序。
- 选择“查看 + 创建”以查看设置。
- 选择“创建”,完成资源创建。
故障排除
使用以下步骤解决常见错误。
无法访问 Prometheus 终结点
当提供程序设置验证操作失败并显示代码 PrometheusURLConnectionFailure
时:
- 检查为节点导出程序配置的默认端口 9100 或自定义端口是否处于打开状态,并在 Linux 主机上侦听。
- 尝试重启节点导出程序代理:
- 转到安装节点导出程序的文件夹(文件名类似于
node_exporter-<xxxx>-amd64
)。 - 运行
./node_exporter
。 - 运行
nohup ./node_exporter &
命令以启用node_exporter。 将 nohup 和 > 添加到上述命令会将node_exporter与 linux 计算机命令行分离。 如果不包含node_exporter将在命令行关闭时停止。
- 转到安装节点导出程序的文件夹(文件名类似于
- 验证 Prometheus 终结点是否可从创建适用于 SAP 解决方案资源的 Azure Monitor 时提供的子网访问。
建议
使用此建议进行故障排除
启用节点导出程序
- 运行命令
nohup ./node_exporter &
以启用node_exporter
。 - 从 Linux 计算机命令行添加
nohup
并&
添加到上述命令node_exporter
。 如果未包含它们,node_exporter
请在命令行关闭时停止。