当前位置:网站首页>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和主机名,再重复以上的启动操作
边栏推荐
猜你喜欢

2022 ByteDance daily practice experience (Tiktok)

每日一题(2022-07-02)——最低加油次数

LeetCode第300场周赛(20220703)

2022年字节跳动日常实习面经(抖音)

What types of Thawte wildcard SSL certificates provide

Halcon template matching

神经网络物联网应用技术就业前景【欢迎补充】

Scala basic tutorial -- 19 -- actor

Deleting nodes in binary search tree

奥迪AUDI EDI INVOIC发票报文详解
随机推荐
IBM WebSphere MQ检索邮件
DeFi生态NFT流动性挖矿系统开发搭建
How to open an account is safe,
Basic tutorial of scala -- 16 -- generics
php伪原创api对接方法
Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers
2021 合肥市信息学竞赛小学组
IBM WebSphere MQ retrieving messages
PB的扩展DLL开发(超级篇)(七)
Angry bird design based on unity
Digital "new" operation and maintenance of energy industry
数组中的第K个最大元素
正则替换【JS,正则表达式】
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
Wireshark抓包TLS协议栏显示版本不一致问题
An example of multi module collaboration based on NCF
A method of using tree LSTM reinforcement learning for connection sequence selection
[uniapp] uniapp development app online Preview PDF file
问下各位大佬有用过cdc直接mysql to clickhouse的么
Li Kou brush question diary /day2/2022.6.24