唐僧还在拜佛求经路。  

1:下载安装包,最新版本根据官方为准;(创建下载目录,以便安装过后清理掉)

cd /usr/local/
wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz

 

 

 2:解压缩 node_exporter-0.18.1.linux-amd64.tar.gz

tar -xvzf /usr/local/node_exporter-0.18.1.linux-amd64.tar.gz && mv node_exporter-0.18.1.linux-amd64 node_exporter
chown -R prome:prome /usr/local/node_exporter/ && cd node_exporter

 

 

 3:压缩成功后,可以运行 version 检查运行环境是否正常

# ./node_exporter --version
  node_exporter, version 0.18.1 (branch: HEAD, revision: 3db77732e925c08f675d7404a8c46466b2ece83e)
  build user: root@b50852a1acba
  build date: 20190604-16:41:18
  go version: go1.12.5

 

 

 

 

 4:启动node_exporter

# ./node_exporter &

 

 5:设置node_exporter组件自启

#sudo vim /lib/systemd/system/node_exporter.service
[Unit]
Description=node_exporter

[Service]
User=prome
ExecStart=/usr/local/node_exporter/node_exporter
# --web.listen-address=:9100\

[Install]
WantedBy=multi-user.target

 

 

 

 

 

 

 

 6:node_exporter脚本重启

#vim /home/prome/node-exporter.sh
#!/bin/bash
if [ -z "$1" ]
then
echo "node-exporter restart/stop/start"
exit 1
fi

START=$1
if [ $START = restart ]
then
ps -ef|grep "node_exporter"|grep -v grep|awk '{print $2}' |xargs kill -9
sleep 2
/usr/local/node_exporter/node_exporter &>> /var/log/node_exporter/node_exporter.log &
echo "node_exporter restart"

elif [ $START = stop ]
then
ps -ef|grep "node_exporter"|grep -v grep|awk '{print $2}' |xargs kill -9
echo "node_exporter stop"

elif [ $START = start ]
then
/usr/local/node_exporter/node_exporter &>> /var/log/node_exporter/node_exporter.log &
echo "node_exporter start"
fi

#chmod +x /home/prome/node-exporter.sh
#sudo ln -s /home/prome/node-exporter.sh /etc/init.d/node-exporter

posted on 2020-04-03 08:32  唐僧还在拜佛求经路。  阅读(353)  评论(0编辑  收藏  举报