prometheus二进制安装

news2024/10/2 20:23:31

1、在需要安装prometheus的目录下执行wget命令下载软件到本地,如我的路径是/opt/module/prometheus

wget https://github.com/prometheus/prometheus/releases/download/v2.34.0/prometheus-2.34.0.linux-amd64.tar.gz

正在解析主机 objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.111.133, 185.199.109.133, ...
正在连接 objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:76299772 (73M) [application/octet-stream]
正在保存至: “prometheus-2.34.0.linux-amd64.tar.gz”

100%[========================================================================================>] 76,299,772  15.7MB/s 用时 5.3s   

2023-12-24 11:51:25 (13.9 MB/s) - 已保存 “prometheus-2.34.0.linux-amd64.tar.gz” [76299772/76299772])

表示下载已完成
查看

[root@ambari-hadoop1 prometheus]# ll
总用量 74512
-rw-r--r-- 1 root root   76299772 315 2022 prometheus-2.34.0.linux-amd64.tar.gz

解压

[root@ambari-hadoop1 prometheus]# tar -zxvf prometheus-2.34.0.linux-amd64.tar.gz 
prometheus-2.34.0.linux-amd64/
prometheus-2.34.0.linux-amd64/consoles/
prometheus-2.34.0.linux-amd64/consoles/index.html.example
prometheus-2.34.0.linux-amd64/consoles/node-cpu.html
prometheus-2.34.0.linux-amd64/consoles/node-disk.html
prometheus-2.34.0.linux-amd64/consoles/node-overview.html
prometheus-2.34.0.linux-amd64/consoles/node.html
prometheus-2.34.0.linux-amd64/consoles/prometheus-overview.html
prometheus-2.34.0.linux-amd64/consoles/prometheus.html
prometheus-2.34.0.linux-amd64/console_libraries/
prometheus-2.34.0.linux-amd64/console_libraries/menu.lib
prometheus-2.34.0.linux-amd64/console_libraries/prom.lib
prometheus-2.34.0.linux-amd64/prometheus.yml
prometheus-2.34.0.linux-amd64/LICENSE
prometheus-2.34.0.linux-amd64/NOTICE
prometheus-2.34.0.linux-amd64/prometheus
prometheus-2.34.0.linux-amd64/promtool

解压后查看

[root@ambari-hadoop1 prometheus]# ll
总用量 74512
drwxr-xr-x 4 3434 3434      132 315 2022 prometheus-2.34.0.linux-amd64
-rw-r--r-- 1 root root 76299772 315 2022 prometheus-2.34.0.linux-amd64.tar.gz

删除压缩文件

[root@ambari-hadoop1 prometheus]# rm -rf prometheus-2.34.0.linux-amd64.tar.gz 

2、创建开机启动项

vim /usr/lib/systemd/system/prometheus.service

配置内容如下

[Unit]
Description=prometheus
Documentation=https://prometheus.io/
After=network.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/opt/module/prometheus/prometheus-2.34.0.linux-amd64/prometheus --config.file=/opt/module/prometheus/prometheus-2.34.0.linux-amd64/prometheus.yml
Restart=on-failure

[Install]
WantedBy=multi-user.target

设置自动启动:

$ systemctl enable prometheus

报错

[root@ambari-hadoop1 system]# systemctl enable prometheus
Failed to execute operation: File exists

原因:之前安装过prometheus,没有卸载干净
接下来卸载之前安装的prometheus文件
先查找

[root@ambari-hadoop1 system]# find / -name prometheus.service
/etc/systemd/system/multi-user.target.wants/prometheus.service
/usr/lib/systemd/system/prometheus.service

删除第一个文件,第二个文件是刚刚自己创建的prometheus.service

[root@ambari-hadoop1 system]#  rm -rf /etc/systemd/system/multi-user.target.wants/prometheus.service

再次查看

[root@ambari-hadoop1 system]# find / -name prometheus.service
/usr/lib/systemd/system/prometheus.service

设置开机启动

[root@ambari-hadoop1 system]# systemctl enable prometheus
Created symlink from /etc/systemd/system/multi-user.target.wants/prometheus.service to /usr/lib/systemd/system/prometheus.service.

启动服务并查看启动状态:

# 重新加载某个服务的配置文件
$ systemctl daemon-reload
# 启动prometheus
$ systemctl start prometheus
# 查看prometheus状态
$ systemctl status prometheus

[root@ambari-hadoop1 system]# systemctl status prometheus
● prometheus.service - prometheus
   Loaded: loaded (/usr/lib/systemd/system/prometheus.service; enabled; vendor preset: disabled)
   Active: active (running) since 日 2023-12-24 12:08:55 CST; 5s ago
     Docs: https://prometheus.io/
 Main PID: 3960 (prometheus)
    Tasks: 9
   Memory: 19.4M
   CGroup: /system.slice/prometheus.service
           └─3960 /opt/module/prometheus/prometheus-2.34.0.linux-amd64/prometheus --config.file=/opt/module/prometheus/promethe...

1224 12:08:55 ambari-hadoop1 prometheus[3960]: ts=2023-12-24T04:08:55.726Z caller=head.go:493 level=info component=tsd... any"
12月 24 12:08:55 ambari-hadoop1 prometheus[3960]: ts=2023-12-24T04:08:55.726Z caller=head.go:536 level=info component=tsd…=5.31µs
12月 24 12:08:55 ambari-hadoop1 prometheus[3960]: ts=2023-12-24T04:08:55.726Z caller=head.go:542 level=info component=tsd...hile"
1224 12:08:55 ambari-hadoop1 prometheus[3960]: ts=2023-12-24T04:08:55.727Z caller=head.go:613 level=info component=tsd...ent=0
1224 12:08:55 ambari-hadoop1 prometheus[3960]: ts=2023-12-24T04:08:55.727Z caller=head.go:619 level=info component=tsd…0.235µs
1224 12:08:55 ambari-hadoop1 prometheus[3960]: ts=2023-12-24T04:08:55.727Z caller=main.go:958 level=info fs_type=XFS_S...MAGIC
1224 12:08:55 ambari-hadoop1 prometheus[3960]: ts=2023-12-24T04:08:55.727Z caller=main.go:961 level=info msg="TSDB started"
1224 12:08:55 ambari-hadoop1 prometheus[3960]: ts=2023-12-24T04:08:55.727Z caller=main.go:1142 level=info msg="Loading...s.yml
12月 24 12:08:55 ambari-hadoop1 prometheus[3960]: ts=2023-12-24T04:08:55.728Z caller=main.go:1179 level=info msg="Completed lo…µs
1224 12:08:55 ambari-hadoop1 prometheus[3960]: ts=2023-12-24T04:08:55.728Z caller=main.go:910 level=info msg="Server i...sts."
Hint: Some lines were ellipsized, use -l to show in full.

3、访问prometheus页面查看 http协议+prometheus安装主机的ip地址+端口号

http://192.168.0.21:9090

在这里插入图片描述
在页面Status------>targets查看节点信息
在这里插入图片描述4、在本机上安装Node-exporter客户端采集数据
NodeExporter 是 Prometheus 官方提供的一个可以采集到主机信息的应用程序,它能采集到机器的 CPU、内存、磁盘等信息。作为基础的组件,一般在所有的节点都都会安装。
从prometheus官网找https://prometheus.io/download/ 获取最新的 Node Exporter 版本的二进制包:

https://prometheus.io/download/

在这里插入图片描述
下载node_exporter-1.7.0.linux-amd64.tar.gz

[root@ambari-hadoop1 node-exporter]# ll
总用量 10176
-rw-r--r-- 1 root root 10419253 1224 13:22 node_exporter-1.7.0.linux-amd64.tar.gz
[root@ambari-hadoop1 node-exporter]# pwd
/opt/module/prometheus/node-exporter

解压

[root@ambari-hadoop1 node-exporter]# pwd
/opt/module/prometheus/node-exporter
[root@ambari-hadoop1 node-exporter]# tar -zxvf node_exporter-1.7.0.linux-amd64.tar.gz 
node_exporter-1.7.0.linux-amd64/
node_exporter-1.7.0.linux-amd64/LICENSE
node_exporter-1.7.0.linux-amd64/node_exporter
node_exporter-1.7.0.linux-amd64/NOTICE
[root@ambari-hadoop1 node-exporter]# ll
总用量 10176
drwxr-xr-x 2 1001 1002       56 1113 08:03 node_exporter-1.7.0.linux-amd64
-rw-r--r-- 1 root root 10419253 1224 13:22 node_exporter-1.7.0.linux-amd64.tar.gz

在解压后的目录下后台运行

[root@ambari-hadoop1 node_exporter-1.7.0.linux-amd64]# pwd
/opt/module/prometheus/node-exporter/node_exporter-1.7.0.linux-amd64

运行node Exporter ,指定为8080端口运行


# 前台运行
$ ./node_exporter --web.listen-address 192.168.0.21:8080
# 后台运行
$ nohup ./node_exporter --web.listen-address 192.168.0.21:8080 >> nohup.out 2>&1 &
[root@ambari-hadoop1 node_exporter-1.7.0.linux-amd64]# pwd
/opt/module/prometheus/node-exporter/node_exporter-1.7.0.linux-amd64
[root@ambari-hadoop1 node_exporter-1.7.0.linux-amd64]# nohup ./node_exporter --web.listen-address 192.168.0.21:8080 >> nohup.out 2>&1 &
[1] 9032

查看node-exporter运行成功后的页面

http://192.168.0.21:8080

在这里插入图片描述
在这里插入图片描述
配置prometheus的监控数据源

现在我们运行了 Prometheus 服务器,也运行了业务数据源 NodeExporter。但此时 Prometheus 还获取不到任何数据,我们还需要配置下 prometheus.yml 文件,让其去拉取 Node Exporter 的数据

prometheus.yml并在 scrape_configs 节点下添加以下内容:

[root@ambari-hadoop1 prometheus-2.34.0.linux-amd64]# pwd
/opt/module/prometheus/prometheus-2.34.0.linux-amd64
[root@ambari-hadoop1 prometheus-2.34.0.linux-amd64]# ll
总用量 197372
drwxr-xr-x 2 3434 3434        38 315 2022 console_libraries
drwxr-xr-x 2 3434 3434       173 315 2022 consoles
drwxr-xr-x 2 root root         6 1224 12:01 data
-rw-r--r-- 1 3434 3434     11357 315 2022 LICENSE
-rw-r--r-- 1 3434 3434      3773 315 2022 NOTICE
-rwxr-xr-x 1 3434 3434 105137495 315 2022 prometheus
-rw-r--r-- 1 3434 3434       934 315 2022 prometheus.yml
-rwxr-xr-x 1 3434 3434  96946761 315 2022 promtool
[root@ambari-hadoop1 prometheus-2.34.0.linux-amd64]# 

修改路径下的prometheus.yml文件
下方为原先有的文件

[root@ambari-hadoop1 prometheus-2.34.0.linux-amd64]# vim prometheus.yml 

# 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-exporter'
    static_configs:
      - targets: ['localhost:8080']

修改后的配置文件

# 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-exporter'
    static_configs:
      - targets: ['localhost:8080']

注意:每次修改配置完成,用promtool检测配置文件是否正确

$ ./promtool check config ./prometheus.yml

[root@ambari-hadoop1 prometheus-2.34.0.linux-amd64]# ./promtool check config ./prometheus.yml
Checking ./prometheus.yml
 SUCCESS: ./prometheus.yml is valid prometheus config file syntax

重启prometheus

$  systemctl restart prometheus

在这里插入图片描述

重启后发现增加了node-exporter的信息,状态为up

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1332393.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Head First Design Patterns - 策略模式

策略模式 策略模式&#xff1a;策略模式是一种行为型模式&#xff0c;它将对象和行为分开&#xff0c;将行为定义为 一个行为接口 和 具体行为的实现。策略模式最大的特点是行为的变化&#xff0c;行为之间可以相互替换。每个if判断都可以理解为就是一个策略。本模式使得算法可…

05_符号表

05_符号表 一、符号表符号表API设计符号表实现有序符号表 一、符号表 符号表最主要的目的就是将一个键和一个值联系起来&#xff0c;符号表能够将存储的数据元素是一个键和一个值共同组成的键值对数据&#xff0c;我们可以根据键来查找对应的值。符号表中&#xff0c;键具有唯…

2024华为OD机试真题指南宝典—持续更新(JAVAPythonC++JS)【彻底搞懂算法和数据结构—算法之翼】

PC端可直接搜索关键词 快捷键&#xff1a;CtrlF 年份关键字、题目关键字等等 注意看本文目录-快速了解本专栏 文章目录 &#x1f431;2024年华为OD机试真题&#xff08;马上更新&#xff09;&#x1f439;2023年华为OD机试真题&#xff08;更新中&#xff09;&#x1f436;新…

1.倒排索引 2.逻辑斯提回归算法

1.倒排索引 https://help.aliyun.com/zh/open-search/retrieval-engine-edition/introduction-to-inverted-indexes 倒排索引&#xff08;Inverted Index&#xff09;是一种数据结构&#xff0c;用于快速查找包含某个特定词或词语的文档。它主要用于全文搜索引擎等应用&#…

解锁JDK 12的奇妙之旅:新特性详解

欢迎来到我的博客&#xff0c;代码的世界里&#xff0c;每一行都是一个故事 解锁JDK 12的奇妙之旅&#xff1a;新特性详解 前言switch表达式拓展NumberFormat对复杂数字的格式化字符串支持transform、indent操作新增方法Files.mismatch(Path, Path)Teeing Collector支持unicode…

AG16KDDF256 User Manual

AGM AG16KDDF256 是由 AGM FPGA AG16K 与 DDR-SDRAM 叠封集成的芯片&#xff0c;具有 AG16K FPGA的可编程功能&#xff0c;提供更多可编程 IO&#xff0c;同时内部连接大容量 DDR-SDRAM。  FPGA 外部管脚 FBGA256 封装&#xff0c;管脚说明请见下表 Table-1&#xff1a; Tab…

微服务实战系列之Dubbo(上)

前言 随着一年一度冬至的到来&#xff0c;2023的步伐也将远去。而博主的系列文章&#xff0c;也将从今天起&#xff0c;越来越聚焦如何构建微服务“内核”上。前序系列文章几乎囊括了微服务的方方面面&#xff0c;无论使用什么框架、组件或工具&#xff0c;皆可拿来用之。 那么…

探秘JDK 13的黑科技:新特性一览

欢迎来到我的博客&#xff0c;代码的世界里&#xff0c;每一行都是一个故事 探秘JDK 13的黑科技&#xff1a;新特性一览 前言switch表达式扩展Switch表达式的基本概念&#xff1a;使用Switch表达式的优势&#xff1a;示例代码&#xff1a;注意事项和最佳实践&#xff1a; Text …

【面向对象】对比JavaScript、Go、Ada、Python、C++、Java、PHP的访问限制。

在不同编程语言中&#xff0c;控制成员&#xff08;变量、方法、类等&#xff09;可见性的机制不尽相同。以下是对比JavaScript、Go、Ada、Python、C、Java、PHP所使用的访问限制关键字和约定&#xff1a; 一、JavaScript ### JavaScript访问限制 早期的JavaScript并没有类似…

Selenium4+Python3 - Iframe、Select控件、交互式弹出框、执行JS、Cookie操作

一、iframe操作 iframe识别&#xff1a; 语法&#xff1a; driver.switch_to.frame(‘方式’) 1、常见处理方法三种 index&#xff1a;下标name&#xff1a;id或name属性的值webelement&#xff1a;元素 2、通过下标进入 进入第一个iframe&#xff1a; driver.switch_to.…

【什么是反射机制?为什么反射慢?】

✅ 什么是反射机制&#xff1f;为什么反射慢&#xff1f; ✅典型解析✅拓展知识仓✅反射常见的应用场景✅反射和Class的关系 ✅典型解析 反射机制指的是程序在运行时能够获取自身的信息。在iava中&#xff0c;只要给定类的名字&#xff0c;那么就可以通过反射机制来获得类的所有…

C++笔试训练day_2

文章目录 选择题7. 编程题1.2. 选择题 &#xff08;6&#xff09;因为p2被const修饰所以p2不可以被改变&#xff0c;但是p2的指向可以被改变 &#xff08;7&#xff09;因为指针p3被const修饰&#xff0c;所以p3的指向不能被改变&#xff0c;但是*p3可以被改变 int main() {in…

spring boot集成mybatis和springsecurity实现权限控制功能

上一篇已经实现了登录认证功能&#xff0c;这一篇继续实现权限控制功能&#xff0c;文中代码只贴出来和上一篇不一样的修改的地方&#xff0c;完整代码可结合上一篇一起整理spring boot集成mybatis和springsecurity实现登录认证功能-CSDN博客 数据库建表 权限控制的意思就是根…

前端常用的工具网站

前端常用的工具网站&#x1f516; 文章目录 前端常用的工具网站&#x1f516;1. 图片在线压缩2. iconfont--矢量图标3. JSON在线格式化4. EMOJIALL--表情符号5. removebg--去除图片背景6. FREE API--免费API接口7. Lorem picsum --随机图片8.UU在线工具 -- 聚合工具 1. 图片在线…

Windows系统安装 ffmpeg

下载及解压 ffmpeg官方下载地址&#xff1a;https://ffmpeg.org/download.html 下载好后将其解压至你想保存的位置中。 环境变量设置 打开Windows设置&#xff0c;在搜索框输入&#xff1a;系统高级设置。 新建环境变量&#xff0c;并输入bin目录具体位置。 安装检查 按住 w…

图形处理工具:Photoshop Elements 2020 mac介绍说明

Photoshop Elements 2020 mac简称ps elements 2020&#xff0c;是一款图形处理工具。ps elements 2020 mac可以帮助您自动生成照片和视频作品的功能&#xff0c;采用Sensei AI技术可进行图像组织、编辑和创建等。Photoshop Elements 2020 可以帮助您轻松整理照片和视频&#xf…

【Linux】定时任务

定时任务常用crontab来定期执行程序。 crontab 基本语法 crontab [-u user] -l # 列出用户cron任务 crontab [-u user] -e # 编辑用户cron任务 crontab [-u user] -r # 移除用户cron任务cron 表达式 # 分 时 日 月 周 执行命令 minute hour day month week command # 示例…

Simulink元件

constant 输出常数/标量 这样我们就只输出了一个常数 输出一维数组/矢量 这样我们就输出了1-5一共5个数字 输出二维数组 这样我们就输出了4个数字 选择框Interpret vector parameters as 1-D 如果标量或者矩阵&#xff0c;勾与不勾都一样。 如果是向量&#xff0c;勾选则表…

Keil中文报错提示为: [-Winvalid-source-encoding]问题解决

错误提示&#xff1a; ../User/main.c(67): warning: illegal character encoding in string literal [-Winvalid-source-encoding]67 | printf("全<B2><BF><B4><AB><CA><E4><CD><EA><B3><C9…

java旅游攻略管理系统Myeclipse开发mysql数据库web结构java编程计算机网页项目

一、源码特点 java Web旅游攻略管理系统是一套完善的java web信息管理系统&#xff0c;对理解JSP java编程开发语言有帮助&#xff0c;系统具有完整的源代码和数据库&#xff0c;系统主要采用B/S模式开发。开发环境为 TOMCAT7.0,Myeclipse8.5开发&#xff0c;数据库为Mysql…