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

Prometheus 1:安装(Centos7)

1. 同步时间

        因Prometheus对时间精度要求高,所以安装前,需要与NTP同步时间:

#设置系统显示时区为 亚洲上海
timedatectl set-timezone Asia/Shanghai#同步当地时间
ntpdate -u cn.pool.ntp.org

2. 同步时间后,从官网下载Prometheus安装包

#可以通过wget命令直接从官网下载,也可以通过其它方式导入
wget https://github.com/prometheus/prometheus/releases/download/v2.54.0/prometheus-2.54.0.linux-amd64.tar.gz

3.下载完成后,使用tar命令解压缩Prometheus

[root@localhost ~]# tar -zxvf prometheus-2.54.0.linux-amd64.tar.gz

4. 启动Prometheus

[root@localhost prometheus-2.54.0.linux-amd64]# ./prometheus 
ts=2024-08-21T06:58:50.462Z caller=main.go:601 level=info msg="No time or size retention was set so using the default time retention" duration=15d
ts=2024-08-21T06:58:50.462Z caller=main.go:645 level=info msg="Starting Prometheus Server" mode=server version="(version=2.54.0, branch=HEAD, revision=5354e87a70d3eb26b81b601b286d66ff983990f6)"
ts=2024-08-21T06:58:50.462Z caller=main.go:650 level=info build_context="(go=go1.22.6, platform=linux/amd64, user=root@68a9e2472a68, date=20240809-11:36:32, tags=netgo,builtinassets,stringlabels)"
ts=2024-08-21T06:58:50.462Z caller=main.go:651 level=info host_details="(Linux 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 localhost.localdomain (none))"
ts=2024-08-21T06:58:50.462Z caller=main.go:652 level=info fd_limits="(soft=4096, hard=4096)"
ts=2024-08-21T06:58:50.463Z caller=main.go:653 level=info vm_limits="(soft=unlimited, hard=unlimited)"
ts=2024-08-21T06:58:50.465Z caller=web.go:571 level=info component=web msg="Start listening for connections" address=0.0.0.0:9090
ts=2024-08-21T06:58:50.466Z caller=main.go:1160 level=info msg="Starting TSDB ..."
ts=2024-08-21T06:58:50.468Z caller=tls_config.go:313 level=info component=web msg="Listening on" address=[::]:9090
ts=2024-08-21T06:58:50.468Z caller=tls_config.go:316 level=info component=web msg="TLS is disabled." http2=false address=[::]:9090
ts=2024-08-21T06:58:50.472Z caller=head.go:626 level=info component=tsdb msg="Replaying on-disk memory mappable chunks if any"
ts=2024-08-21T06:58:50.472Z caller=head.go:713 level=info component=tsdb msg="On-disk memory mappable chunks replay completed" duration=5.209µs
ts=2024-08-21T06:58:50.472Z caller=head.go:721 level=info component=tsdb msg="Replaying WAL, this may take a while"
ts=2024-08-21T06:58:50.473Z caller=head.go:793 level=info component=tsdb msg="WAL segment loaded" segment=0 maxSegment=1
ts=2024-08-21T06:58:50.473Z caller=head.go:793 level=info component=tsdb msg="WAL segment loaded" segment=1 maxSegment=1
ts=2024-08-21T06:58:50.473Z caller=head.go:830 level=info component=tsdb msg="WAL replay completed" checkpoint_replay_duration=242.215µs wal_replay_duration=594.489µs wbl_replay_duration=151ns chunk_snapshot_load_duration=0s mmap_chunk_replay_duration=5.209µs total_replay_duration=866.148µs
ts=2024-08-21T06:58:50.475Z caller=main.go:1181 level=info fs_type=XFS_SUPER_MAGIC
ts=2024-08-21T06:58:50.475Z caller=main.go:1184 level=info msg="TSDB started"
ts=2024-08-21T06:58:50.475Z caller=main.go:1367 level=info msg="Loading configuration file" filename=prometheus.yml
ts=2024-08-21T06:58:50.476Z caller=main.go:1404 level=info msg="updated GOGC" old=100 new=75
ts=2024-08-21T06:58:50.476Z caller=main.go:1415 level=info msg="Completed loading of configuration file" filename=prometheus.yml totalDuration=993.215µs db_storage=3.554µs remote_storage=2.506µs web_handler=293ns query_engine=2.105µs scrape=665.522µs scrape_sd=22.979µs notify=26.899µs notify_sd=7.721µs rules=2.86µs tracing=12.976µs
ts=2024-08-21T06:58:50.476Z caller=main.go:1145 level=info msg="Server is ready to receive web requests."
ts=2024-08-21T06:58:50.476Z caller=manager.go:164 level=info component="rule manager" msg="Starting rule manager..."

5. 默认工作端口是9090,如果无法访问,可能是服务器的9090端口没有开启,需要

#通过sudo firewall-cmd --list-all查看当前启用端口
[root@localhost prometheus]# sudo firewall-cmd --list-all
public (active)target: defaulticmp-block-inversion: nointerfaces: ens32sources: services: ssh dhcpv6-clientports: protocols: masquerade: noforward-ports: source-ports: icmp-blocks: rich rules: 

经查如果没有开启,需要

#开启服务器访问端口,prometheus默认端口为9090,其它端口参照
[root@localhost prometheus]# sudo firewall-cmd --zone=public --add-port=9090/tcp --permanent
success#重启防火墙
[root@localhost prometheus]# sudo firewall-cmd --reload
success#检查当前启用端口
[root@localhost prometheus]# sudo firewall-cmd --list-all
public (active)target: defaulticmp-block-inversion: nointerfaces: ens32sources: services: ssh dhcpv6-clientports: 9090/tcp 9100/tcpprotocols: masquerade: noforward-ports: source-ports: icmp-blocks: rich rules: 

6. 通过浏览器访问prometheus

至此,Prometheus完成安装。


http://www.mrgr.cn/news/4517.html

相关文章:

  • ant design pro v6 如何做好角色管理
  • WHAT - Lodash 的替代 es-toolkit
  • [第五空间 2021]EasyCleanup
  • Mysql高级 [Linux版] 性能优化 数据库系统配置优化 和 MySQL的执行顺序 以及 Mysql执行引擎介绍
  • datawind可视化查询-类型转换函数
  • MySQL 安装与配置指南
  • python爬虫入门
  • 面试题 08.06. 汉诺塔问题(整活版)(不讲武德)
  • p8 Run的流程和Docker原理
  • DOM型XSS
  • oracel数据库的增删改查示例
  • 勇闯计算机视觉(第一关--环境激活)
  • 端点安全新纪元:EDR与XDR技术的融合应用
  • c++ opencv开发环境搭建
  • 性能优化理论篇 | swap area是个什么东西
  • C#学习之路day2
  • mysql查询慢
  • 新手友好:易于上手的10款项目管理工具推荐
  • 浅析JavaScript 堆内存及其通过 Chrome DevTools 捕获堆快照的方法
  • CSS(源码+lw+部署文档+讲解等)