当前位置:网站首页>node_exporter部署
node_exporter部署
2022-07-04 17:40:00 【码道人】
首先查看当前服务器的centos的版本
cat /etc/centos-release
被监控的服务器操作:
一、下载安装包(解压、改名字)
centos7:
wget https://github.com/prometheus/node_exporter/releases/download/v1.3.0/node_exporter-1.3.0.linux-amd64.tar.gzcentos6:
可以直接去网页上https://github.com/prometheus/nodeexporter/releases/download/v1.3.0/nodeexporter-1.3.0.linux-amd64.tar.gz直接下载
上传到要被监控的服务器上解压至目录/usr/local/
解压:
tar xf node_exporter-1.3.0.linux-amd64.tar.gz -C /usr/local/ cd /usr/local/mv node_exporter-1.3.0.linux-amd64/ node_exporter二、配置文件,分为centos6和centos7的方法
centos7的方法
没有则创建目录与文件/usr/lib/systemd/system/node_exporter.service
创建目录:mkdir
创建文件:touch
#vi /usr/lib/systemd/system/node_exporter.service[unit]
Description=The node_exporter Server
After=network.target
[Service]
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
RestartSec=15s
SyslogIdentifier=node_exporter
[Install]
WantedBy=multi-user.targetwq保存退出
#systemctl daemon-reload #systemctl enable node_exporter #systemctl restart node_exporter# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 128 *:9100 *:* centos6
vi /etc/init.d/node_exporte里面的注释也要加进去,不加进去会报错
在文件中添加如下内容
#!/bin/bash
# chkconfig: 2345 10 90
# description: node_exporter
# 20220630
case "$1" in
start)
nohup /usr/local/node_exporter >/usr/local/logs/node_exporter.log 2>&1 &
echo "node_exporter started"
;;
stop)
ps -ef | grep node_exporter | grep -v grep | awk '{print "kill -9 "$2}' | sh
echo "node_exporter stoped"
;;
esac:wq保存退出
配置文件可执行权限
#chmod +x /etc/init.d/node_exporter将node_exporter添加到系统服务
#chkconfig --add node_exporter开启或者关闭node_exporter
service node_exporter startservice node_exporter stop开启node_exporter.service自启动
chkconfig node_exporter on三、去配置prometheus主机上的/usr/local/prometheus/prometheus.yml增加被监控的服务器,以下是整个源码,localhost不需要改,只需要添加最后的ip
vim /usr/local/prometheus/prometheus.ymlglobal:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 15s
alerting:
alertmanagers:
# static_configs:
#- targets: [localhost:9093]
# - localhost:9093
scrape_configs:
- job_name: prometheus
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
static_configs:
- targets:
- localhost:9090
- job_name: node
static_configs:
- targets: ['localhost:9100']
- job_name: node1
static_configs:
- targets: ['192.168.0.xxx:9100']:wq保存退出
检查配置文件是否正确,有报错则修改
./promtool check config prometheus.yml四、启动prometheus命令
在prometheus主机上启动:
/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml &&启动9100
docker run -d --name node_exporter --restart=always -p 9100:9100 prom/node-exporter去网页上打开http://192.168.0.125:9090/targets?search= 有多个job_name生成且状态up则部署完成

若启动不成功:如报错err="error starting web server: listen tcp 0.0.0.0:9090: bind: address already in use则进行以下步骤;
lsof -i:9090杀掉进程
kill -9 进程号若还不成功则去/usr/local/prometheus/data/,一定是自己的安装prometheus/data目录下
rm -rf lock【//我之前是用docker安装的所以也要在docker里面杀掉,
docker psdocker stop 容器id查看进程
docker ps -a杀掉进程
docker rm 进程号查看容器
docker images删除容器
docker rmi 容器id】
主机重新启动prometheus
/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml 比较有用的参考:
启动prometheus遇到的问题 :
https://blog.csdn.net/wyp257/article/details/118326062 https://zhuanlan.zhihu.com/p/66631919 https://blog.csdn.net/apple198942/article/details/119780818Prometheus怎么用来帮助解决性能问题之入门篇: https://blog.csdn.net/shandeai520/article/details/102865729
理论知识 :https://yunlzheng.gitbook.io/prometheus-book/part-ii-prometheus-jin-jie/grafana/grafana-intro
ps:Prometheus的配置文件最好的是:直接用自带的,自己加参数,要注意空格与换行,每次改完参数之后校验:./promtool check config prometheus.yml
若所有的都没问题,网页上其他节点还是不出来,那就在主机 vim /etc/hosts 配置上被监控的ip和主机名,再重复以上的启动操作
边栏推荐
- Scala basic tutorial -- 12 -- Reading and writing data
- Uni app and uviewui realize the imitation of Xiaomi mall app (with source code)
- Scala basic tutorial -- 17 -- Collection
- 工厂从自动化到数字孪生,图扑能干什么?
- C language printing exercise
- 读写关闭的channel是啥后果?
- File processing examples of fopen, FREAD, fwrite, fseek
- Nature Microbiology | 可感染阿斯加德古菌的六种深海沉积物中的病毒基因组
- repeat_P1002 [NOIP2002 普及组] 过河卒_dp
- Wanghongru research group of Institute of genomics, Chinese Academy of Agricultural Sciences is cordially invited to join
猜你喜欢

2022CoCa: Contrastive Captioners are Image-Text Fountion Models

英特尔集成光电研究最新进展推动共封装光学和光互连技术进步

vbs或vbe如何修改图标

神经网络物联网应用技术学什么

Build your own website (15)
![[mathematical modeling of graduate students in Jiangxi Province in 2022] analysis and code implementation of haze removal by nucleation of water vapor supersaturation](/img/da/d46cca19f34223d29003be2e33aaa4.png)
[mathematical modeling of graduate students in Jiangxi Province in 2022] analysis and code implementation of haze removal by nucleation of water vapor supersaturation

读写关闭的channel是啥后果?
![[go ~ 0 to 1] read, write and create files on the sixth day](/img/cb/b6785ad7d7c7df786f718892a0c058.png)
[go ~ 0 to 1] read, write and create files on the sixth day

Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers

物联网应用技术的就业前景和现状
随机推荐
Wireshark packet capturing TLS protocol bar displays version inconsistency
Scala basic tutorial -- 14 -- implicit conversion
Basic tutorial of scala -- 16 -- generics
请教一下 flinksql中 除了数据统计结果是状态被保存 数据本身也是状态吗
Wanghongru research group of Institute of genomics, Chinese Academy of Agricultural Sciences is cordially invited to join
使用FTP
基于lex和yacc的词法分析器+语法分析器
Scala基础教程--20--Akka
启牛开的证券账户安全吗?
利用策略模式优化if代码【策略模式】
Process of manually encrypt the mass-producing firmware and programming ESP devices
ESP32-C3入门教程 问题篇⑫——undefined reference to rom_temp_to_power, in function phy_get_romfunc_addr
完善的js事件委托
Improve the accuracy of 3D reconstruction of complex scenes | segmentation of UAV Remote Sensing Images Based on paddleseg
Installation and use of VMware Tools and open VM tools: solve the problems of incomplete screen and unable to transfer files of virtual machines
Interpretation of SIGMOD '22 hiengine paper
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
Deleting nodes in binary search tree
《看完就懂系列》字符串截取方法substr() 、 slice() 和 substring()之间的区别和用法
神经网络物联网是什么意思通俗的解释