5

CentOS Install Node Exporter

 1 year ago
source link: https://en.liqiang.io/post/centos-install-node-exporter-en-606da7d6?lang=US_EN
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Overview

Describes how to manually install Node Exporter under CentOS and manage it with Systemd.

Installation

Create a user



  1. [[email protected]]# adduser node_exporter

Install node exporter



  1. [[email protected]]# cd /home/node_exporter
  2. [[email protected]]# wget https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz
  3. [[email protected]]# tar zxf node_exporter-1.5.0.linux-amd64.tar.gz && \
  4. ln -s node_exporter-1.5.0.linux-amd64 node_exporter && \
  5. chown -R node_exporter:node_exporter node_exporter && \
  6. chown -R node_exporter:node_exporter node_exporter-1.5.0.linux-amd64 && \
  7. cd node_exporter
  8. [[email protected]]# touch /etc/sysconfig/node_exporter && echo 'OPTIONS="--collector.textfile.directory /var/lib/node_exporter/textfile_collector"' > /etc/sysconfig/node_exporter
  9. [[email protected]]# mkdir -p /var/lib/node_exporter/textfile_collector && \
  10. chown node_exporter:node_exporter /var/lib/node_exporter/textfile_collector
  11. [[email protected]]# cat <<EOF> /usr/lib/systemd/system/node_exporter.service
  12. [Unit]
  13. Description=Node Exporter
  14. [Service]
  15. User=node_exporter
  16. EnvironmentFile=/etc/sysconfig/node_exporter
  17. ExecStart=/bin/sh -c '/home/node_exporter/node_exporter/node_exporter \$OPTIONS'
  18. [Install]
  19. WantedBy=multi-user.target
  20. EOF
  21. [[email protected]]# systemctl daemon-reload
  22. [[email protected]]# systemctl enable node_exporter
  23. [[email protected]]# systemctl start node_exporter

Config

If you want to change anything in the configuration then this can be done directly by modifying: /etc/sysconfig/node_exporter this file.

Cleanup

If you want to uninstall it, you can use these steps.



  1. [[email protected]]# systemctl stop node_exporter
  2. [[email protected]]# unlink node_exporter
  3. [[email protected]]# rm -rf node_exporter-1.5.0.linux-amd64
  4. [[email protected]]# userdel -r node_exporter
  5. [[email protected]]#
  6. [[email protected]]# rm -rf /var/lib/node_exporter
  7. [[email protected]]# rm -rf /etc/sysconfig/node_exporter
  8. [[email protected]]# rm -f /usr/lib/systemd/system/node_exporter.service

If that’s too much trouble, then you can use this script:



  1. [[email protected]]# cat <<EOF> /tmp/uninstall-node-exporter.sh
  2. systemctl stop node_exporter
  3. unlink /home/node_exporter/node_exporter
  4. userdel -r node_exporter
  5. rm -rf /var/lib/node_exporter
  6. rm -rf /etc/sysconfig/node_exporter
  7. rm -f /usr/lib/systemd/system/node_exporter.service
  8. EOF
  9. [[email protected]]# sh /tmp/uninstall-node-exporter.sh

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK