云计算学习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)

相关推荐
星火开发设计7 分钟前
C++ queue 全面解析与实战指南
java·开发语言·数据结构·c++·学习·知识·队列
落笔画忧愁e1 小时前
实测:利用腾讯云锐驰型 200M 带宽,搭建无门槛高清视频分发系统
云计算·腾讯云
如果你想拥有什么先让自己配得上拥有1 小时前
近似数的思考学习
学习
ha20428941942 小时前
Linux操作系统学习记录之----自定义协议(网络计算器)
linux·网络·学习
振华说技能2 小时前
SolidWorks学习大纲-从基础到全面精通,请看详情
学习
曦月逸霜2 小时前
离散数学-学习笔记(持续更新中~)
笔记·学习·离散数学
im_AMBER2 小时前
Leetcode 101 对链表进行插入排序
数据结构·笔记·学习·算法·leetcode·排序算法
Mr -老鬼2 小时前
Rust与Go:从学习到实战的全方位对比
学习·golang·rust
laplace01232 小时前
# 第四章|智能体经典范式构建 —— 学习笔记(详细版)
笔记·学习
程序猿零零漆2 小时前
Spring之旅 - 记录学习 Spring 框架的过程和经验(十四)SpringMVC的请求处理
学习·spring·pandas