linux-安装promethus监控平台

文章详细介绍了如何部署Linux操作系统监控组件node_exporter和Prometheus,包括下载、上传、解压、启动及配置过程。之后,文章提到通过修改node_exporter端口避免冲突,并展示了在Prometheus中配置监控目标的成功标志。最后,文章提到了使用Grafana导入监控模板以可视化Linux服务器的性能数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 部署 Linux 操作系统监控组件

1. 下载监控 Linux 的 exporter
https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_expor
ter-0.18.1.linux-amd64.tar.gz
2. 将 node_exporter 包上传到需要被监控的 Linux 服务器上任意目录下,执行解压命
tar xvf node_exporter-0.18.1.linux-amd64.tar.gz
3. 进入到解压后的文件夹中,执行启动脚本
nohup ./node_exporter &
查看 nohup 日志:tail -100 nohup.out,出现如下日志,代表启动成功

 部署 prometheus

1、 下载包
https://github.com/prometheus/prometheus/releases/download/v2.15.2/promethe
us-2.15.2.linux-amd64.tar.gz
2、 将 prometheus 上传到一台单独的 Linux 机器上,执行解压操作
tar xvf prometheus-2.15.2.linux-amd64.tar.gz
3、 进入到解压后的文件夹中,修改配置文件,添加要监控的服务器信息 10.0.0.71
vi prometheus.yml
在 scrape_configs 配置项下添加 Linux 监控的 job,其中
IP 修改为上面部署 node_exporter 机器的 ip,端口号为 9100,注意缩进
- job_name: 'node'
static_configs:
- targets: ['10.0.0.71:9100']

# my global config
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["localhost:9090"]
      
  - job_name: "node"
    static_configs:
      - targets: ["192.168.88.151:9100"]

4、 保存配置文件,启动 prometheus
nohup ./prometheus &
检查 nohup.out 日志,如果有以下信息,启动成功

在浏览器中访问部署的 prometheus:http://ip:9090  

点击菜单栏“Status-Targets”,看到页面中有如下 node 节点,代表 prometheus 和
node_exporter 链接成功

注意

  • 因其他业务已占用9100端口,需修改为其他端口
# 启动时指定端口
$ nohup ./node_exporter --web.listen-address=:7100 & 

Grafana导入监控模板 

添加promethus数据源

 输入URL点击保存

 导入监控模板

打开 grafana 官网,查找官网提供的 prometheus 监控模板
https://grafana.com/grafana/dashboards
点击 Linux 服务器监控的模板,记录该模板的 id:11074

 

在 grafana 系统页面中,通过 id 导入该模板,即可在 grafana 中看到 机器
的性能监控数据

 

选择刚刚添加的promethus数据源

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值