云计算学习100天-第40天 -普罗米修斯1

目录

Prometheus

概述------

安装prometheus

案例

环境说明

实验步骤

一、prometheus服务器配置时间同步

二、安装Prometheus服务器

配置文件说明

三、编写服务启动文件并启动服务

四、访问web页面


Prometheus

概述------

Prometheus是一个开源系统监控和警报工具包,最初由 SoundCloud构建。

是一款监控软件,也是一个时序数据库。Prometheus 将其指标收集并存储为时间序列数据,即指标信息与记录时的时间戳以及称为标签的可选键值对一起存储。

主要用在容器监控方面,也可以用于常规的主机监控。

使用google公司开发的go语言编写。

Prometheus是一个框架,可以与其他组件完美结合。

重视高可用,准确性达不到100%

服务名:prometheus

服务端口:9090

安装prometheus

你可以从Prometheus官网下载安装包,然后上传到服务器进行解压安装

Download | Prometheus 找到合适的安装包进行下载

案例

环境说明

|------------|----------------|---------------|
| 主机名称 | IP地址 | 功能 |
| prometheus | 192.168.88.5 | prometheus服务器 |
| web1 | 192.168.88.100 | web服务器 |
| web2 | 192.168.88.200 | web服务器 |

实验步骤

一、 prometheus服务器 配置时间同步

方法一:计划任务方式

#创建定时任务:

*/2 * * * * /sbin/ntpdate ntp1.aliyun.com &>/dev/null

方法二:chrony服务方式

#安装chrony:

dnf -y install chrony

#配置chrony:

vim /etc/chrony.conf

#添加或修改服务器配置:

server [目标IP/域名] iburst

#启动服务:

systemctl enable chronyd --now

#验证同步状态:

chronyc sources

方法三:timedatectl工具

#查看时区:

timedatectl

#设置时区:

timedatectl set-timezone Asia/Shanghai

#查看当前时间:

date

#手动修改时间:

date -s "YYYY-MM-DD HH:MM:SS"

二、 安装Prometheus服务器

#拷贝Prometheus相关软件包到服务器,解压即部署

root@prometheus \~\]# cd prometheus_soft/ \[root@prometheus prometheus_soft\]# tar xf prometheus-2.37.5.linux-amd64.tar.gz \[root@prometheus prometheus_soft\]# mv prometheus-2.37.5.linux-amd64 /usr/local/prometheus ###### **配置文件说明** 配置文件中包含三个配置块:global、rule_files和scrape_configs。 global块控制 Prometheus 服务器的全局配置。我们有两个选择。第一个,scrape_interval控制 Prometheus 抓取目标的频率。您可以为单个目标覆盖它。在这种情况下,全局设置是每 15 秒抓取一次。该evaluation_interval选项控制 Prometheus 评估规则的频率。Prometheus 使用规则来创建新的时间序列并生成警报。 rule_files块指定我们希望 Prometheus 服务器加载的任何规则的位置。现在我们还没有规则。 最后一个块,scrape_configs控制 Prometheus 监控的资源。由于 Prometheus 还将有关自身的数据公开为 HTTP 端点,因此它可以抓取和监控自身的健康状况。在默认配置中,有一个名为 的作业prometheus,用于抓取 Prometheus 服务器公开的时间序列数据。该作业包含一个单一的、静态配置的目标,即localhost的9090端口。Prometheus期望度量在/metrics路径上的目标上可用,所以这个默认作业是通过 URL 抓取的:[http://localhost:9090/metrics](http://localhost:9090/metrics "http://localhost:9090/metrics")。 ##### ******三、编写服务启动文件并启动服务****** \[root@prometheus prometheus_soft\]# vim /usr/lib/systemd/system/prometheus.service \[Unit

Description=Prometheus Monitoring System #服务描述

After=network.target #在网络服务启动后运行

#启动命令指定了配置文件路径(--config.file)和数据存储路径(--storage.tsdb.path)

Service

ExecStart=/usr/local/prometheus/prometheus \

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

--storage.tsdb.path=/usr/local/prometheus/data/

Install

WantedBy=multi-user.target #设置为多用户模式下启动

启动服务

root@prometheus prometheus_soft\]# systemctl daemon-reload \[root@prometheus prometheus_soft\]# systemctl enable prometheus.service --now \[root@prometheus prometheus_soft\]# ss -tlnp \| grep :9090 LISTEN 0 128 \*:9090 \*:\* users:(("prometheus",pid=4396,fd=7)) ##### ******四、访问web页面****** [http://192.168.88.5:9090/](http://192.168.88.5:9090/ "http://192.168.88.5:9090/") 查看监控自身的数据,如分配置给Prometheus运行的内存数量 ![](https://i-blog.csdnimg.cn/direct/db21a6add3ca471098f75110bd76828c.jpeg) ![](https://i-blog.csdnimg.cn/direct/37f54f798ffd400eaae4c08c2bc09b8e.jpeg) ![](https://i-blog.csdnimg.cn/direct/811eb115ef2d4177b5c822b7fea0ac80.jpeg) ![](https://i-blog.csdnimg.cn/direct/349857d76d81446f9f0c65cb55f10b8e.jpeg) ![](https://i-blog.csdnimg.cn/direct/56fd2cd00b334559ac19baa2671b16aa.jpeg)

相关推荐
charlie1145141914 小时前
Kotlin编程学习记录2
开发语言·学习·kotlin·循环·条件
xkroy5 小时前
创建Spring MVC和注解
学习·spring·mvc
XZSSWJS9 小时前
机器视觉学习-day09-图像矫正
学习
Lynnxiaowen12 小时前
今天我们继续学习shell编程语言的内容
linux·运维·学习·云计算·bash
白菜帮张同学13 小时前
LP嵌入式软件/驱动开发笔试/面试总结
数据结构·驱动开发·经验分享·笔记·学习·算法·面试
zl2914 小时前
论文学习30:LViT: Language Meets Vision Transformerin Medical Image Segmentation
深度学习·学习·计算机视觉·transformer
爱隐身的官人15 小时前
爬虫基础学习 - Beautifulsoup
爬虫·学习·beautifulsoup
diablobaal15 小时前
云计算学习100天-第44天-部署邮件服务器
学习·云计算
dbdr090115 小时前
Linux 入门到精通,真的不用背命令!零基础小白靠「场景化学习法」,3 个月拿下运维 offer,第二十四天
linux·运维·c语言·python·学习