当前位置:网站首页>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.gz
centos6:
可以直接去网页上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.target
wq保存退出
#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 start
service node_exporter stop
开启node_exporter.service自启动
chkconfig node_exporter on
三、去配置prometheus主机上的/usr/local/prometheus/prometheus.yml增加被监控的服务器,以下是整个源码,localhost不需要改,只需要添加最后的ip
vim /usr/local/prometheus/prometheus.yml
global:
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 ps
docker 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/119780818
Prometheus怎么用来帮助解决性能问题之入门篇: 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和主机名,再重复以上的启动操作
边栏推荐
- ESP32-C3入门教程 问题篇⑫——undefined reference to rom_temp_to_power, in function phy_get_romfunc_addr
- Behind the ultra clear image quality of NBA Live Broadcast: an in-depth interpretation of Alibaba cloud video cloud "narrowband HD 2.0" technology
- ByteDance dev better technology salon was successfully held, and we joined hands with Huatai to share our experience in improving the efficiency of web research and development
- How is the entered query SQL statement executed?
- Scala基础教程--17--集合
- 基于C语言的菜鸟驿站管理系统
- What if the self incrementing ID of online MySQL is exhausted?
- 未来几年中,软件测试的几大趋势是什么?
- 启牛开的证券账户安全吗?
- 神经网络物联网应用技术就业前景【欢迎补充】
猜你喜欢
基于C语言的菜鸟驿站管理系统
神经网络物联网是什么意思通俗的解释
Angry bird design based on unity
神经网络物联网应用技术就业前景【欢迎补充】
A method of using tree LSTM reinforcement learning for connection sequence selection
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
Scala基础教程--20--Akka
英特尔集成光电研究最新进展推动共封装光学和光互连技术进步
使用canal配合rocketmq监听mysql的binlog日志
激进技术派 vs 项目保守派的微服务架构之争
随机推荐
2022年字节跳动日常实习面经(抖音)
李迟2022年6月工作生活总结
LeetCode 赎金信 C#解答
英特尔集成光电研究最新进展推动共封装光学和光互连技术进步
神经网络物联网应用技术学什么
Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片
File processing examples of fopen, FREAD, fwrite, fseek
Li Kou brush question diary /day3/2022.6.25
TorchDrug教程
sqlserver的CDC第一次查询的能读取到数据,但后面增删改读取不到,是什么原因
Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers
How to open an account is safe,
从实时应用角度谈通信总线仲裁机制和网络流控
工厂从自动化到数字孪生,图扑能干什么?
MXNet对GoogLeNet的实现(并行连结网络)
ByteDance dev better technology salon was successfully held, and we joined hands with Huatai to share our experience in improving the efficiency of web research and development
2022养生展,健康展,北京大健康展,健康产业展11月举办
vbs或vbe如何修改图标
How to modify icons in VBS or VBE
Scala basic tutorial -- 13 -- advanced function