linux安装node_exporter

一、下载并解压 node_exporter

cd /opt

# 下载最新版本(v1.8.1)
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.1/node_exporter-1.8.1.linux-amd64.tar.gz

# 解压缩
tar -xvf node_exporter-1.8.1.linux-amd64.tar.gz

# 重命名
mv node_exporter-1.8.1.linux-amd64 node_exporter

# 可选:赋权
chmod +x /opt/node_exporter/node_exporter

二、创建 systemd 服务配置文件

sudo vim /etc/systemd/system/node_exporter.service

关键启动参数

[Unit]
Description=Prometheus Node Exporter
After=network.target

[Service]
User=nobody
ExecStart=/opt/node_exporter/node_exporter \
  --collector.processes \
  --collector.systemd \
  --collector.logind \
  --collector.cpu \
  --collector.meminfo \
  --collector.filesystem \
  --collector.netstat \
  --collector.netdev \
  --collector.diskstats \
  --collector.time \
  --collector.uname \
  --collector.loadavg

Restart=on-failure

[Install]
WantedBy=multi-user.target

三、启动并设置开机自启

# 重载 systemd 配置
sudo systemctl daemon-reload

# 设置开机启动
sudo systemctl enable node_exporter

# 启动服务
sudo systemctl start node_exporter

# 查看状态
sudo systemctl status node_exporter

四、验证是否成功

# 查看监听端口(默认9100)
ss -lntp | grep 9100

# 或访问
curl http://localhost:9100/metrics

# 验证某个采集器是否生效(例如 processes)
curl -s http://localhost:9100/metrics | grep node_processes

五、Prometheus 配置文件中添加目标

编辑你的 prometheus.yml

scrape_configs:
  - job_name: 'node_exporter'
    static_configs:
      - targets: ['<你的服务器IP>:9100']

然后重启 Prometheus:

systemctl restart prometheus


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值