Linux 下搭建 node_exporter+Prometheus+Grafana 服务器性能监控平台

windows安装请参考: https://blog.csdn.net/qq_41554118/article/details/118309457

https://github.com/prometheus/prometheus 【官网】

https://prometheus.io/download/ 【Prometheus 各模块下载 】

模版下载

node_exporter官网

官方安装指导:

node_exporter下载地址

prometheus下载地址

docker安装参考:https://www.cnblogs.com/momoyan/p/11520676.html

grafana 安装下载地址

grafana 各系统安装下载

node_exporter安装

二进制包安装

#创建目录
mkdir -p /opt/exporter
cd /opt/exporter
#下载安装包
wget https://github.com/prometheus/prometheus/releases/tag/v2.28.0/node_exporter-1.1.2.linux-arm64.tar.gz
#解压
tar -xvzf  node_exporter-1.1.2.linux-arm64.tar.gz
#修改名称
mv nnode_exporter-1.1.2.linux-arm64 node_exportercd /opt/exporter/node_exporter
#修改权限
chmod 777 node_exporter
#后台启动服务
nohup /opt/exporter/node_exporter/node_exporter &
#访问
curl http://IP:9100/metrics

推荐自启动安装:下载包上传解压后

###
cd /etc/systemd/system/
vim node_exporter.service

[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target
 
[Service]
Type=simple
User=root
ExecStart=/media/monitor/node_exporter/node_exporter
Restart=on-failure
 
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
###
systemctl enable node_exporter.service
systemctl start node_exporter.service
systemctl status node_exporter.service
 
systemctl stop node_exporter.service
service node_exporter restart

###浏览器输入地址访问
http://127.0.0.1:9100/metrics
在这里插入图片描述

2、prometheus 安装

cd /media/monitor/prometheus
mkdir {data,cfg,logs,bin} -p
mv prometheus promtool bin/
mv prometheus.yml cfg/
cd /media/monitor/prometheus/cfg

vim prometheus.yml

scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'node_exporter'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
 
    static_configs:
    - targets: ['localhost:9100']
 

vim /etc/profile

#prometheus
export PROMETHEUS_HOME=/usr/grafana/prometheus-2.10.0
export PATH=$PATH:${PROMETHEUS_HOME}/bin

source /etc/profile

cd /etc/systemd/system/
vim prometheus.service

[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target
 
[Service]
Type=simple
User=prometheus
ExecStart=/usr/grafana/prometheus-2.10.0/bin/prometheus --config.file=/usr/grafana/prometheus-2.10.0/cfg/prometheus.yml --storage.tsdb.path=/usr/grafana/prometheus-2.10.0/data
Restart=on-failure
 
[Install]
#下面两者选择一个,我也不知道哪个是绝对正确的。
#因为我装了两台服务器,第一台服务器用第一个配置可以正常运行,
#第二胎服务器就必须用第二个配置才能运行
WantedBy=multi-user.target
#WantedBy=default.target

systemctl daemon-reload

systemctl enable prometheus.service
systemctl start prometheus.service
systemctl status prometheus.service

systemctl stop prometheus.service
service prometheus restart

###浏览器输入地址访问
http://127.0.0.1:9090/

在这里插入图片描述

3、grafana

3.1、安装

下载:https://grafana.com/grafana/download

Linux安装

wget https://dl.grafana.com/oss/release/grafana-8.0.3.linux-arm64.tar.gz
tar -zxvf grafana-8.0.3.linux-amd64.tar.gz

cd /media/monitor//grafana

tar -zxvf grafana-8.0.3.linux-arm64.tar.gz
/media/monitor/grafana/bin/
./grafana-server

//设置脚本启动没有成功,报错:code=exited, status=1/FAILURE
vim grafana.service

[Unit]
Description=grafana
Documentation=https://prometheus.io/
After=network.target
 
[Service]
Type=simple
User=root
ExecStart=/media/monitor/grafana-8.0.3/bin/grafana-server
Restart=on-failure
 
[Install]
WantedBy=multi-user.target

systemctl enable grafanaservice
systemctl start grafana.service
systemctl status grafana.service

systemctl stop grafana.service
service grafana restart

###浏览器输入地址访问
http://127.0.0.1:3000/

3.2、配置

(1)配置数据库
在这里插入图片描述

(2)导入模板
模板下载地址:https://github.com/starsliao/Prometheus/tree/master/node_exporter
中文模版

最终效果如下:
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值