# 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