当前位置: 首页 > news >正文

Prometheus安装及使用(二进制方式)

一、Prometheus简介

1、Prometheus是什么

Prometheus是一个开源系统监控和警报工具,最初由 SoundCloud创建。自 2012 年以来,许多公司和组织都采用了 Prometheus,该项目拥有非常活跃的开发者和用户社区。

它现在是一个独立的开源项目,独立于任何公司进行维护。为了强调这一点,并明确项目的治理结构,Prometheus 于 2016 年作为继Kubernetes之后的第二个托管项目加入了云原生计算基金会(CNCF)。

2、Prometheus官方网址

https://prometheus.io/docs/introduction/overview/

二、Prometheus安装环境准备

实验环境

修改主机名

hostnamectl set-hostname xxx

三、Prometheus安装(prometheus-server)

1、下载或上传prometheus-2.37.8.linux-amd64.tar.gz包到/root目录

下载方式:wget https://github.com/prometheus/prometheus/releases/download/v2.37.8/prometheus-2.37.8.linux-amd64.tar.gz

2、Prometheus安装

tar xf prometheus-2.37.8.linux-amd64.tar.gz

mv prometheus-2.37.8.linux-amd64 /usr/local/prometheus

3、修改Prometheus配置文件

cd /usr/local/prometheus/

vim prometheus.yml

修改:

4、启动Prometheus

nohup ./prometheus --config.file=prometheus.yml &

ps aux | grep prometheus

ss -anpt | grep 9090

5、将Prometheus托管给systemd

pkill prometheus

cat > /usr/lib/systemd/system/prometheus.service << EOF

[Service]

ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml

[Install]

WantedBy=multi-user.target

[Unit]

Description=prometheus

After=network.target

EOF

重新加载 systemd 单元文件

systemctl daemon-reload

systemctl enable --now prometheus

systemctl status prometheus

yum -y install lsof

列出正在使用指定端口(这里是 9090 端口)的进程和相关文件

lsof -i:9090

ps -ef | grep prometheus

四、Prometheus UI界面访问

可以通过运行Prometheus server节点IP+9090端口对Prometheus进行访问

使用浏览器访问192.168.10.14:9090

五、使用Prometheus监控Prometheus server及其它主机

1、对Prometheus server主机监控(prometheus-server)

(1)下载node_exporter或上传node_exporter-1.6.0.linux-amd64.tar.gz包到/root目录

下载方法:wget https://github.com/prometheus/node_exporter/releases/download/v1.6.0/node_exporter-1.6.0.linux-amd64.tar.gz

(2)安装node_exporter

tar xf node_exporter-1.6.0.linux-amd64.tar.gz

mv node_exporter-1.6.0.linux-amd64 /usr/local/node_exporter

cd /usr/local/node_exporter/

(3)启动node_exporter

nohup ./node_exporter &

ss -anpt | grep node_exporter

ss -anpt | grep 9100

(4)注册为systemd管理的系统服务

pkill node_exporter

cat > /usr/lib/systemd/system/node_exporter.service << EOF

[Service]

ExecStart=/usr/local/node_exporter/node_exporter

[Install]

WantedBy=multi-user.target

[Unit]

Description=node_exporter

After=network.target

EOF

systemctl daemon-reload

systemctl enable --now node_exporter

systemctl status node_exporter

(5)修改Prometheus Server配置文件添加node节点

cd /usr/local/prometheus/

vim prometheus.yml

添加:

  - job_name: "prometheus-server"

    static_configs:

      - targets: ["192.168.10.14:9100"]

systemctl restart prometheus

2、对其它主机进行监控(以192.168.10.15为例)

(1)下载node_exporter或上传node_exporter-1.6.0.linux-amd64.tar.gz包到/root目录(prometheus-agent)

下载方法:wget https://github.com/prometheus/node_exporter/releases/download/v1.6.0/node_exporter-1.6.0.linux-amd64.tar.gz

(2)安装node_exporter(prometheus-agent)

tar xf node_exporter-1.6.0.linux-amd64.tar.gz

mv node_exporter-1.6.0.linux-amd64 /usr/local/node_exporter

cd /usr/local/node_exporter/

(3)启动node_exporter(prometheus-agent)

nohup ./node_exporter &

ss -anpt | grep node_exporter

(4)注册为systemd管理的系统服务(prometheus-agent)

pkill node_exporter

cat > /usr/lib/systemd/system/node_exporter.service << EOF

[Service]

ExecStart=/usr/local/node_exporter/node_exporter

[Install]

WantedBy=multi-user.target

[Unit]

Description=node_exporter

After=network.target

EOF

systemctl daemon-reload

systemctl enable --now node_exporter

systemctl status node_exporter

(5)修改Prometheus Server配置文件添加node节点(prometheus-server)

cd /usr/local/prometheus/

vim prometheus.yml

添加:

  - job_name: "prometheus-agent"

    static_configs:

      - targets: ["192.168.10.15:9100"]

systemctl restart prometheus

相关文章:

  • ansible-playbook 进阶 接上一章内容
  • pikachu通关教程-目录遍历漏洞(../../)
  • 【AI-安装指南】Redis Stack 的安装与使用
  • LNMP环境中php7.2升级到php7.4
  • [JVM] JVM内存调优
  • SQL面试提问 :如何计算每个月的订单数量和总金额以及与上个月相比的环比增长率
  • TCP通信与MQTT协议的关系
  • HAProxy 可观测性最佳实践
  • Maven---配置本地仓库
  • 【数据集】基于累计分布函数匹配CDF Matching与多分辨率卡尔曼滤波MKF相结合的地表温度(2002-2020)
  • 交叉编译tcpdump工具
  • 如何优化微信小程序中渲染带有图片的列表(二进制流存储方式的图片存在本地数据库)
  • 图解gpt之注意力机制原理与应用
  • (一)微服务(垂直AP/分布式缓存/装饰器Pattern)
  • Kubernetes 入门:安装 kubectl 并掌握基础命令
  • 将材质球中的纹理属性对应的贴图保存至本地
  • ES6 深克隆与浅克隆详解:原理、实现与应用场景
  • 华为云Flexus+DeepSeek征文|基于华为云Dify平台打造个人知识库聊天机器人全流程指南
  • 每日算法-250530
  • leetcode538.把二叉搜索树转换为累加树:反向中序遍历的数值累加之道
  • 炫酷手机网站模板/免费二级域名申请网站
  • 建设网站技术公司/电脑版百度入口
  • 深圳网站优讳化/百度推广注册
  • ae模板精品站/如何创建一个app平台
  • 国外色情 网站 推荐/社会新闻最新消息
  • 外贸soho网站制作/优化网站的软件下载