部署prometheus

news/2024/5/19 1:19:48 标签: linux, 运维, prometheus

prometheus_0">部署prometheus

1. 环境

主机IP
监控机192.168.72.141
被监控机192.168.72.139

2. 部署

2.1 安装go环境

[root@master prometheus]# dnf -y install go
上次元数据过期检查:4:22:23 前,执行于 2021年11月24日 星期三 21时00分43秒。
依赖关系解决。
============================================
 软件包     架构   版本     仓库       大小
============================================
安装:
 golang     x86_64 1.17.2-2.module_el8.6.0+9

[root@master local]# go version
go version go1.17.2 linux/amd64

prometheus_23">2.2安装prometheus

prometheus-2.31.1.linux-amd64.tar.gz

2.2.1 安装

[root@master src]# ls
apr-1.7.0
apr-1.7.0.tar.gz
apr-util-1.6.1
apr-util-1.6.1.tar.gz
debug
httpd-2.4.49
httpd-2.4.49.tar.gz
kernels
prometheus-2.31.1.linux-amd64.tar.gz
[root@master src]# tar xf prometheus-2.31.1.linux-amd64.tar.gz -C /usr/local/
[root@master src]# cd /usr/local/
[root@master local]# ls
apache    lib
apr       lib64
apr+      libexec
apr-util  prometheus-2.31.1.linux-amd64
bin       sbin
etc       share
games     src
include
[root@master local]# mv prometheus-2.31.1.linux-amd64/ prometheus
[root@master local]# ls
apache    bin      lib         sbin
apr       etc      lib64       share
apr+      games    libexec     src
apr-util  include  prometheus

2.2.2 启动

[root@master prometheus]# ./prometheus --config.file=/usr/local/prometheus/prometheus.yml &

2.2.3 验证

在这里插入图片描述

2.2.4 以服务的方式启动

[root@master prometheus]# cat /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus Monitoring System
Documentation=Prometheus Monitoring System
 
[Service]
ExecStart=/usr/local/prometheus/prometheus \
  --config.file=/usr/local/prometheus/prometheus.yml \
  --web.listen-address=:9090
Restart=on-failure
[Install]
WantedBy=multi-user.target

[root@master prometheus]# systemctl enable --now prometheus
Created symlink /etc/systemd/system/multi-user.target.wants/prometheus.service → /etc/systemd/system/prometheus.service.

[root@master prometheus]# 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            0.0.0.0:4505             0.0.0.0:*                       
LISTEN  0       128            0.0.0.0:4506             0.0.0.0:*                       
LISTEN  0       128                  *:9090                   *:*                       
LISTEN  0       128                  *:80                     *:*                       
LISTEN  0       128               [::]:22                  [::]:*                       

2.3 在被控机上安装 node-exporter

node_exporter-1.3.0.linux-amd64.tar.gz

2.3.1安装

[root@node1 ~]# cd /usr/src/
[root@node1 src]# ls
debug
haproxy-2.5.0
kernels
mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
redis-6.2.6
[root@node1 src]# ls
debug
haproxy-2.5.0
kernels
mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
node_exporter-1.3.0.linux-amd64.tar.gz
redis-6.2.6
[root@node1 src]# tar xf node_exporter-1.3.0.linux-amd64.tar.gz -C /usr/local/
[root@node1 local]# mv node_exporter-1.3.0.linux-amd64/ node_exporter
[root@node1 local]# ls
bin  games    include  lib64    mysql                                node_exporter  sbin   src
etc  haproxy  lib      libexec  mysql-5.7.35-linux-glibc2.12-x86_64  redis          share

[root@node1 local]# cd node_exporter/
[root@node1 node_exporter]# ./node_exporter 
ts=2021-11-25T07:00:26.673Z caller=node_exporter.go:182 level=info msg="Starting node_exporter" version="(version=1.3.0, branch=HEAD, revision=c65f870ef90a4088210af0319498b832360c3366)"
ts=2021-11-25T07:00:26.673Z caller=node_exporter.go:183 level=info msg="Build context" b

2.3.2验证

访问192.168.72.139:9100/metrics,若出现数据则服务开启成功
在这里插入图片描述

2.3.4设置node_exporter 以服务的方式启动并设置开机自启

[root@node1 node_exporter]# vim /etc/systemd/system/node_exporter.service
[root@node1 node_exporter]# cat /etc/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
After=network.target 

[Service]
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure

[Install]
WantedBy=multi-user.target
[root@node1 node_exporter]# systemctl daemon-reload
[root@node1 node_exporter]# systemctl enable --now node_exporter
Created symlink /etc/systemd/system/multi-user.target.wants/node_exporter.service → /etc/systemd/system/node_exporter.service.
[root@node1 node_exporter]# systemctl status node_exporter
● node_exporter.service - node_exporter
   Loaded: loaded (/etc/systemd/system/node>
   Active: active (running) since Thu 2021->
 Main PID: 23749 (node_exporter)
    Tasks: 5 (limit: 11201)
   Memory: 6.9M
   CGroup: /system.slice/node_exporter.serv>
           └─23749 /usr/local/node_exporter>

11月 25 02:05:20 node1 node_exporter[23749]>
11月 25 02:05:20 node1 node_exporter[23749]>
11月 25 02:05:20 node1 node_exporter[23749]>
11月 25 02:05:20 node1 node_exporter[23749]>
11月 25 02:05:20 node1 node_exporter[23749]>
11月 25 02:05:20 node1 node_exporter[23749]>
11月 25 02:05:20 node1 node_exporter[23749]>


[root@node1 node_exporter]# ss -antl
State  Recv-Q  Send-Q   Local Address:Port         Peer Address:Port      Process       
LISTEN 0       5            127.0.0.1:25151             0.0.0.0:*                       
LISTEN 0       25             0.0.0.0:514               0.0.0.0:*                       
LISTEN 0       128            0.0.0.0:6379              0.0.0.0:*                       
LISTEN 0       128            0.0.0.0:22                0.0.0.0:*                       
LISTEN 0       128                  *:443                     *:*                       
LISTEN 0       25                [::]:514                  [::]:*                       
LISTEN 0       80                   *:3306                    *:*                       
LISTEN 0       128                  *:9100                    *:*                       
LISTEN 0       128                  *:80                      *:*                       
LISTEN 0       128               [::]:22                   [::]:*                       

2.4 修改Prometheus 配置,监控Linux机器

2.4.1修改Prometheus配置

进入Prometheus的安装文件夹,打开Prometheus配置文件

[root@master prometheus]# pwd
/usr/local/prometheus
[root@master prometheus]# ls
console_libraries  NOTICE
consoles           prometheus
data               prometheus.yml
LICENSE            promtool
[root@master prometheus]# vim prometheus.yml

在scrape_configs标签下,添加以下内容,配置监控

  - job_name: 'Linux'
    static_configs:
      - targets: ['192.168.72.139:9100']
        labels:
          instance: Linux

2.4.2重启访问

[root@master prometheus]# systemctl restart prometheus

在这里插入图片描述


http://www.niftyadmin.cn/n/1032028.html

相关文章

手机 滑动_LG 卷轴滑动式手机曝光,两侧拉出化身平板电脑

此前在其它友商都在研究内折还是外折的折叠屏手机时,LG创新式推出了旋转的LG Wing手机,吸引了一大波关注。近日,外媒又爆出了LG“滚动式移动终端”手机专利,与市面上其它折叠屏手机同样不同,可谓是十分具有创意。图片来…

SaltStack之salt-ssh

SaltStack之salt-ssh 1. salt-ssh介绍 salt-ssh可以让我们不需要在受控机上安装salt-minion客户端也能够实现管理操作。 1.1 salt-ssh的特点 远程系统需要Python支持,除非使用-r选项发送原始ssh命令salt-ssh是一个软件包,需安装之后才能使用&#xf…

UWA六月直播第四弹-Unity UI模块优化案例精讲,今晚8点不见不散

原文链接:https://blog.uwa4d.com/archives/1827.html UWA即将迎来两周岁生日啦,为答谢所有关注者的支持,UWA两周年庆系列活动第一弹即将亮相:四场精彩技术直播领跑充电季!UWA工程师将从Unity引擎的加载、内存、渲染、…

sql 加一列 数字_sql语句中查询出的数据添加一列,并且添加默认值

查询出数据,并且要添加一列表中都不存在的数据,且这一列的值都是相等的select app_id,app_secret from wx_ticket group by app_id;查询出的数据是app_id | expires_in--------------------------------wxeec89cdf2d435d10 | 7200wxeec89cdf2d435d10 | 7…

SaltStack进阶

SaltStack进阶 1. masterless 1.1 应用场景 master 与 minion 网络不通或通信有延迟,即网络不稳定想在 minion 端直接执行状态 传统的 SaltStack 是需要通过 master 来执行状态控制 minion 从而实现状态的管理,但是当网络不稳定的时候,当想…

UWA 六月直播季 | 6.29 Unity UI模块中的优化案例精讲

原文链接:https://blog.uwa4d.com/archives/1875.html 昨晚,UWA两周年庆之直播充电月最后一弹《Unity UI 模块优化案例精讲》如约而至,UWA当红主播张强对UI模块中常见的性能问题进行了全方位解析,并从(1)如…

salt-syndic分布式架构

salt-syndic分布式架构 1.salt-syndic架构图 2.salt-syndic的优劣势 优势: 可以通过syndic实现更复杂的salt架构 减轻master的负担 劣势: syndic的/srv目录下的salt和pillar目录内容要与最顶层的master下的一致,所以要进行数据同步&#…

mockitoandroid_mockito-android 3.0 使用教程

我们在做单元测试或者其他测试的时候,可以使用Mockito实现Mock对象。dependencies {api org.mockito:mockito-android:3.0.0}如果是非Android 运行环境请使用dependencies {api org.mockito:mockito-core:3.0.0}可能会遇到 Could not initialize plugin: interface …