linux系统下安装node_exporter,并设置自启动

2022年8月12日

首先在https://github.com/prometheus/node_exporter/releases/ 中下载node_exporter安装包,路径如下:

wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
wget https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz

将安装包解压

 tar -xvzf node_exporter-1.3.1.linux-amd64.tar.gz

关闭防火墙

systemctl stop firewalld.service

启动服务(路径为home/exporter/node_exporter-1.2.2.linux-amd64)

./node_exporter

将exporter服务设置为自启动

将文件node_exporter.service放入该路径(/usr/lib/systemd/system Or /etc/systemd/system/ )内容如下

cat /usr/lib/systemd/system/node_exporter.service        or
cat /etc/systemd/system/node_exporter.service
 
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
 
[Unit]
Description=node_exporter
Documentation=node_exporter Monitoring System
After=network.target
 
[Service]
#User=node_exporter
#Group=node_exporter
#node_exporter的路径,根据自己程序所放置的路径填写
ExecStart=/home/prometheus/node_exporter/node_exporter\
          --web.listen-address=0.0.0.0:9100\
 
[Install]
WantedBy=multi-user.target
  1. 设置为自启动服务设置如下
  2. systemctl daemon-reload   重载配置
  3. systemctl start node_exporter  开启服务
  4. systemctl stop node_exporter   关闭服务
  5. systemctl restart node_exporter    重启服务
  6. systemctl status node_exporter    查看服务状态
  7. systemctl enable node_exporter    将服务设置为开机自启动
  8. systemctl disable node_exporter    禁止服务开机自启动
  9. systemctl is-enabled node_exporter    查看服务是否开机启动
  10. systemctl list-unit-files|grep enabled    查看开机启动的服务列表
  11. systemctl --failed    查看启动失败的服务列表

没有评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注