CentOS Install Node Exporter
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.
Overview
Describes how to manually install Node Exporter under CentOS and manage it with Systemd.
Installation
Create a user
[[email protected]]# adduser node_exporter
Install node exporter
[[email protected]]# cd /home/node_exporter
[[email protected]]# wget https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz
[[email protected]]# tar zxf node_exporter-1.5.0.linux-amd64.tar.gz && \
ln -s node_exporter-1.5.0.linux-amd64 node_exporter && \
chown -R node_exporter:node_exporter node_exporter && \
chown -R node_exporter:node_exporter node_exporter-1.5.0.linux-amd64 && \
cd node_exporter
[[email protected]]# touch /etc/sysconfig/node_exporter && echo 'OPTIONS="--collector.textfile.directory /var/lib/node_exporter/textfile_collector"' > /etc/sysconfig/node_exporter
[[email protected]]# mkdir -p /var/lib/node_exporter/textfile_collector && \
chown node_exporter:node_exporter /var/lib/node_exporter/textfile_collector
[[email protected]]# cat <<EOF> /usr/lib/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
[Service]
User=node_exporter
EnvironmentFile=/etc/sysconfig/node_exporter
ExecStart=/bin/sh -c '/home/node_exporter/node_exporter/node_exporter \$OPTIONS'
[Install]
WantedBy=multi-user.target
EOF
[[email protected]]# systemctl daemon-reload
[[email protected]]# systemctl enable node_exporter
[[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.
[[email protected]]# systemctl stop node_exporter
[[email protected]]# unlink node_exporter
[[email protected]]# rm -rf node_exporter-1.5.0.linux-amd64
[[email protected]]# userdel -r node_exporter
[[email protected]]#
[[email protected]]# rm -rf /var/lib/node_exporter
[[email protected]]# rm -rf /etc/sysconfig/node_exporter
[[email protected]]# rm -f /usr/lib/systemd/system/node_exporter.service
If that’s too much trouble, then you can use this script:
[[email protected]]# cat <<EOF> /tmp/uninstall-node-exporter.sh
systemctl stop node_exporter
unlink /home/node_exporter/node_exporter
userdel -r node_exporter
rm -rf /var/lib/node_exporter
rm -rf /etc/sysconfig/node_exporter
rm -f /usr/lib/systemd/system/node_exporter.service
EOF
[[email protected]]# sh /tmp/uninstall-node-exporter.sh
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK