当前位置:网站首页>node_ Exporter deployment
node_ Exporter deployment
2022-07-04 19:34:00 【Code Taoist】
First, check the current server centos Version of
cat /etc/centos-release
Monitored server operations :
One 、 Download installation package ( decompression 、 Change the name )
centos7:
wget https://github.com/prometheus/node_exporter/releases/download/v1.3.0/node_exporter-1.3.0.linux-amd64.tar.gz
centos6:
You can go directly to the web page https://github.com/prometheus/nodeexporter/releases/download/v1.3.0/nodeexporter-1.3.0.linux-amd64.tar.gz Direct download
Upload it to the server to be monitored and unzip it to the directory /usr/local/
decompression :
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
Two 、 The configuration file , It is divided into centos6 and centos7 Methods
centos7 Methods
If not, create directories and files /usr/lib/systemd/system/node_exporter.service
Create directory :mkdir
create a file :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 Save and exit
#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
The notes inside should also be added , If you don't add it, you will report an error
Add the following to the file
#!/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 Save and exit
Configuration file executable permissions
#chmod +x /etc/init.d/node_exporter
take node_exporter Add to system services
#chkconfig --add node_exporter
On or off node_exporter
service node_exporter start
service node_exporter stop
Turn on node_exporter.service Self starting
chkconfig node_exporter on
3、 ... and 、 De configuration prometheus Host computer /usr/local/prometheus/prometheus.yml Add monitored servers , The following is the whole source code ,localhost There is no need to change , Just add the last 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 Save and exit
Check if the configuration file is correct , If there is an error, modify
./promtool check config prometheus.yml
Four 、 start-up prometheus command
stay prometheus Start on host :
/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml &
&
start-up 9100
docker run -d --name node_exporter --restart=always -p 9100:9100 prom/node-exporter
Go to the web page and open http://192.168.0.125:9090/targets?search= There are many. job_name Generated and in state up The deployment is complete
If the startup fails : If the report is wrong err="error starting web server: listen tcp 0.0.0.0:9090: bind: address already in use Then proceed to the following steps ;
lsof -i:9090
Kill the process
kill -9 Process number
If not, go /usr/local/prometheus/data/, It must be your own installation prometheus/data Under the table of contents
rm -rf lock
【// I used to use docker So it should be installed in docker Kill it inside ,
docker ps
docker stop Containers id
Check the process
docker ps -a
Kill the process
docker rm Process number
Look at the container
docker images
Delete container
docker rmi Containers id
】
The host restarts prometheus
/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml
More useful reference :
start-up prometheus Problems encountered :
https://blog.csdn.net/wyp257/article/details/118326062
https://zhuanlan.zhihu.com/p/66631919
https://blog.csdn.net/apple198942/article/details/119780818
Prometheus How to help solve performance problems : https://blog.csdn.net/shandeai520/article/details/102865729
Theoretical knowledge :https://yunlzheng.gitbook.io/prometheus-book/part-ii-prometheus-jin-jie/grafana/grafana-intro
ps:Prometheus The best configuration file is : Just use your own , Add parameters yourself , Pay attention to spaces and line breaks , Check after each parameter change :./promtool check config prometheus.yml
If everything is ok , Other nodes on the web page still don't come out , Then on the host vim /etc/hosts The configuration is monitored ip And the host name , Repeat the above starting operation
边栏推荐
- How to use async Awati asynchronous task processing instead of backgroundworker?
- Online text line fixed length fill tool
- 1672. Total assets of the richest customers
- 基于NCF的多模块协同实例
- 生成XML元素
- 1006 Sign In and Sign Out(25 分)(PAT甲级)
- Comment utiliser async awati asynchrone Task Handling au lieu de backgroundworker?
- 问下各位大佬有用过cdc直接mysql to clickhouse的么
- How test engineers "attack the city" (Part 2)
- From automation to digital twins, what can Tupo do?
猜你喜欢
Go microservice (II) - detailed introduction to protobuf
PolyFit软件介绍
“只跑一趟”,小区装维任务主动推荐探索
勾股数规律(任意三个数能够满足勾股定理需要满足的条件)
Introduction to polyfit software
自由小兵儿
node_exporter部署
Safer, smarter and more refined, Chang'an Lumin Wanmei Hongguang Mini EV?
Pytorch学习(四)
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
随机推荐
Is the securities account opened by qiniu safe?
问下各位大佬有用过cdc直接mysql to clickhouse的么
Add namespace declaration
求2的n次方
Pointnet/Pointnet++点云数据集处理并训练
[uniapp] uniapp development app online Preview PDF file
Reflection (I)
1672. Total assets of the richest customers
爬虫(6) - 网页数据解析(2) | BeautifulSoup4在爬虫中的使用
PointNeXt:通过改进的模型训练和缩放策略审视PointNet++
How to use async Awati asynchronous task processing instead of backgroundworker?
Wechat reading notes of "work, consumerism and the new poor"
YOLOv5s-ShuffleNetV2
English语法_名词 - 使用
There are multiple divs in the large div, which are displayed on the same line. After overflow, scroll bars are generated without line breaks
Use canal and rocketmq to listen to MySQL binlog logs
Pytorch学习(四)
C # implementation defines a set of SQL statements that can be executed across databases in the middle of SQL (detailed explanation of the case)
Summary and sorting of 8 pits of redis distributed lock
Stream流