下载

prometheus的官网的download页面,可以找到prometheus的下载二进制包。

[root@node00 src]# cd /usr/src/
[root@node00 src]# wget https://github.com/prometheus/prometheus/releases/download/v2.12.0/prometheus-2.12.0.linux-amd64.tar.gz
[root@node00 src]# mkdir /usr/local/prometheus/
[root@node00 src]# tar xf prometheus-2.12..linux-amd64.tar.gz -C /usr/local/prometheus/
[root@node00 src]# cd /usr/local/prometheus/
[root@node00 prometheus]# ln -s prometheus-2.12..linux-amd64 prometheus
[root@node00 prometheus]# ll
total
lrwxrwxrwx root root Sep : prometheus -> prometheus-2.12..linux-amd64
drwxr-xr-x Aug : prometheus-2.12..linux-amd64
[root@node00 prometheus]# cd prometheus

获取配置帮助

[root@node00 prometheus]# ./prometheus  --help 

启动

# 启动
[root@node00 prometheus]# ./prometheus
level=info ts=--20T09::.470Z caller=main.go: msg="no time or size retention was set so using the default time retention" duration=15d
level=info ts=--20T09::.470Z caller=main.go: msg="Starting Prometheus" version="(version=2.12.0, branch=HEAD, revision=43acd0e2e93f9f70c49b2267efa0124f1e759e86)"
level=info ts=--20T09::.470Z caller=main.go: build_context="(go=go1.12.8, user=root@7a9dbdbe0cc7, date=20190818-13:53:16)"
level=info ts=--20T09::.470Z caller=main.go: host_details="(Linux 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 node00 (none))"
level=info ts=--20T09::.470Z caller=main.go: fd_limits="(soft=1024, hard=4096)"
level=info ts=--20T09::.470Z caller=main.go: vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=--20T09::.473Z caller=main.go: msg="Starting TSDB ..."
level=info ts=--20T09::.473Z caller=web.go: component=web msg="Start listening for connections" address=0.0.0.0:
level=info ts=--20T09::.519Z caller=head.go: component=tsdb msg="replaying WAL, this may take awhile"
level=info ts=--20T09::.520Z caller=head.go: component=tsdb msg="WAL segment loaded" segment= maxSegment=
level=info ts=--20T09::.520Z caller=main.go: fs_type=XFS_SUPER_MAGIC
level=info ts=--20T09::.520Z caller=main.go: msg="TSDB started"
level=info ts=--20T09::.520Z caller=main.go: msg="Loading configuration file" filename=prometheus.yml
level=info ts=--20T09::.568Z caller=main.go: msg="Completed loading of configuration file" filename=prometheus.yml
level=info ts=--20T09::.568Z caller=main.go: msg="Server is ready to receive web requests."

测试

配置开机自启

# 进入systemd文件目录
[root@node00 system]# cd /usr/lib/systemd/system
# 编写prometheus systemd文件
[root@node00 system]# cat prometheus.service
[Unit]
Description=prometheus
After=network.target [Service]
User=prometheus
Group=prometheus
WorkingDirectory=/usr/local/prometheus/prometheus
ExecStart=/usr/local/prometheus/prometheus/prometheus
[Install]
WantedBy=multi-user.target

# 启动
[root@node00 system]# systemctl restart prometheus
# 查看状态
[root@node00 system]# systemctl status prometheus
● prometheus.service - prometheus
Loaded: loaded (/usr/lib/systemd/system/prometheus.service; disabled; vendor preset: disabled)
Active: active (running) since Fri -- :: EDT; 4s ago
Main PID: (prometheus)
CGroup: /system.slice/prometheus.service
└─ /usr/local/prometheus/prometheus/prometheus Sep :: node00 prometheus[]: level=info ts=--20T10::.634Z caller=head.go: component=tsdb msg="replaying WAL, this may take awhile"
Sep :: node00 prometheus[]: level=info ts=--20T10::.640Z caller=head.go: component=tsdb msg="WAL segment loaded" segment= maxSegment=
Sep :: node00 prometheus[]: level=info ts=--20T10::.640Z caller=head.go: component=tsdb msg="WAL segment loaded" segment= maxSegment=
Sep :: node00 prometheus[]: level=info ts=--20T10::.641Z caller=head.go: component=tsdb msg="WAL segment loaded" segment= maxSegment=
Sep :: node00 prometheus[]: level=info ts=--20T10::.641Z caller=head.go: component=tsdb msg="WAL segment loaded" segment= maxSegment=
Sep :: node00 prometheus[]: level=info ts=--20T10::.642Z caller=main.go: fs_type=XFS_SUPER_MAGIC
Sep :: node00 prometheus[]: level=info ts=--20T10::.642Z caller=main.go: msg="TSDB started"
Sep :: node00 prometheus[]: level=info ts=--20T10::.642Z caller=main.go: msg="Loading configuration file" filename=prometheus.yml
Sep :: node00 prometheus[]: level=info ts=--20T10::.686Z caller=main.go: msg="Completed loading of configuration file" filename=prometheus.yml
Sep :: node00 prometheus[]: level=info ts=--20T10::.686Z caller=main.go: msg="Server is ready to receive web requests." # 开机自启配置
[root@node00 system]# systemctl enable prometheus
Created symlink from /etc/systemd/system/multi-user.target.wants/prometheus.service to /usr/lib/systemd/system/prometheus.service.

后端存储配置

默认情况下prometheus会将采集的数据防止到本机的data目录的, 存储数据的大小受限和扩展不便,这是使用influxdb作为后端的数据库来存储数据。

influxdb安装配置

influxdb的官方文档地址为: https://docs.influxdata.com/influxdb/v1.7/introduction/downloading/ 根据不同系统进行下载,这里使用官方提供的rpm进行安装。

# 下载rpm
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.7.8.x86_64.rpm
# 本地安装rpm
sudo yum localinstall influxdb-1.7..x86_64.rpm
# 查看安装的文件
[root@node00 influxdb]# rpm -ql influxdb
/etc/influxdb/influxdb.conf
/etc/logrotate.d/influxdb
/usr/bin/influx
/usr/bin/influx_inspect
/usr/bin/influx_stress
/usr/bin/influx_tsm
/usr/bin/influxd
/usr/lib/influxdb/scripts/influxdb.service
/usr/lib/influxdb/scripts/init.sh
/usr/share/man/man1/influx..gz
/usr/share/man/man1/influx_inspect..gz
/usr/share/man/man1/influx_stress..gz
/usr/share/man/man1/influx_tsm..gz
/usr/share/man/man1/influxd-backup..gz
/usr/share/man/man1/influxd-config..gz
/usr/share/man/man1/influxd-restore..gz
/usr/share/man/man1/influxd-run..gz
/usr/share/man/man1/influxd-version..gz
/usr/share/man/man1/influxd..gz
/var/lib/influxdb
/var/log/influxdb
# 备份默认的默认的配置文件,这里可以对influxdb的数据存放位置做些设置
[root@node00 influxdb]# cp /etc/influxdb/influxdb.conf  /etc/influxdb/influxdb.conf.default # 启动
[root@node00 influxdb]# systemctl restart influxdb
# 查看状态
[root@node00 influxdb]# systemctl status influxdb # 客户端登陆测试, 创建一个prometheus的database供后续的prometheus使用。
[root@node00 influxdb]# influx
Connected to http://localhost:8086 version 1.7.8
InfluxDB shell version: 1.7.
> show databases;
name: databases
name
----
_internal
> create database prometheus;
> show databases;
name: databases
name
----
_internal
prometheus
> exit

配置prometheus集成infludb

官方的帮助文档在这里: https://docs.influxdata.com/influxdb/v1.7/supported_protocols/prometheus/

[root@node00 prometheus]# pwd
/usr/local/prometheus/prometheus
cp prometheus.yml prometheus.yml.default
vim prometheus.yml
# 添加如下几行
remote_write:
- url: "http://localhost:8086/api/v1/prom/write?db=prometheus" remote_read:
- url: "http://localhost:8086/api/v1/prom/read?db=prometheus" systemctl restart prometheus
systemctl status prometheus

注意: 如果influxdb配置有密码, 请参考上面的官方文档地址进行配置。

测试数据是否存储到influxdb中

[root@node00 prometheus]# influx
Connected to http://localhost:8086 version 1.7.8
InfluxDB shell version: 1.7.
> show databases;
name: databases
name
----
_internal
prometheus
> use prometheus
Using database prometheus
> show measures;
ERR: error parsing query: found measures, expected CONTINUOUS, DATABASES, DIAGNOSTICS, FIELD, GRANTS, MEASUREMENT, MEASUREMENTS, QUERIES, RETENTION, SERIES, SHARD, SHARDS, STATS, SUBSCRIPTIONS, TAG, USERS at line , char
> show MEASUREMENTS;
name: measurements
name
----
go_gc_duration_seconds
go_gc_duration_seconds_count
go_gc_duration_seconds_sum
go_goroutines
go_info
go_memstats_alloc_bytes
# 后面还是有很多,这里不粘贴了。 # 做个简单查询
> select * from prometheus_http_requests_total limit ;
name: prometheus_http_requests_total
time __name__ code handler instance job value
---- -------- ---- ------- -------- --- -----
prometheus_http_requests_total /metrics localhost: prometheus
prometheus_http_requests_total /metrics localhost: prometheus
prometheus_http_requests_total /metrics localhost: prometheus
prometheus_http_requests_total /metrics localhost: prometheus
prometheus_http_requests_total /metrics localhost: prometheus
prometheus_http_requests_total /metrics localhost: prometheus
prometheus_http_requests_total /metrics localhost: prometheus
prometheus_http_requests_total /metrics localhost: prometheus
prometheus_http_requests_total /metrics localhost: prometheus
prometheus_http_requests_total /metrics localhost: prometheus

prometheus学习系列二: Prometheus安装的更多相关文章

  1. RabbitMQ学习系列二-C#代码发送消息

    RabbitMQ学习系列二:.net 环境下 C#代码使用 RabbitMQ 消息队列 http://www.80iter.com/blog/1437455520862503 上一篇已经讲了Rabbi ...

  2. .net reactor 学习系列(二)---.net reactor界面各功能说明

    原文:.net reactor 学习系列(二)---.net reactor界面各功能说明         安装了.net reactor之后,可以在安装目录下找到帮助文档REACTOR_HELP.c ...

  3. 图机器学习(GML)&图神经网络(GNN)原理和代码实现(前置学习系列二)

    项目链接:https://aistudio.baidu.com/aistudio/projectdetail/4990947?contributionType=1 欢迎fork欢迎三连!文章篇幅有限, ...

  4. MyBatis学习系列二——增删改查

    目录 MyBatis学习系列一之环境搭建 MyBatis学习系列二——增删改查 MyBatis学习系列三——结合Spring 数据库的经典操作:增删改查. 在这一章我们主要说明一下简单的查询和增删改, ...

  5. Maven学习系列二(1-5)

    Maven学习系列二(1-5) 本文转自 QuantSeven 博客,讲解精炼易懂,适合入门,链接及截图如下 http://www.cnblogs.com/quanyongan/category/47 ...

  6. scrapy爬虫学习系列二:scrapy简单爬虫样例学习

    系列文章列表: scrapy爬虫学习系列一:scrapy爬虫环境的准备:      http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_python_00 ...

  7. DocX开源WORD操作组件的学习系列二

    DocX学习系列 DocX开源WORD操作组件的学习系列一 : http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_sharp_001_docx1.htm ...

  8. [转]ASP.NET MVC学习系列(二)-WebAPI请求 传参

    [转]ASP.NET MVC学习系列(二)-WebAPI请求 传参 本文转自:http://www.cnblogs.com/babycool/p/3922738.html ASP.NET MVC学习系 ...

  9. Prometheus学习系列(二)之Prometheus FIRST STEPS

    前言 本文来自Prometheus官网手册 和 Prometheus简介 说明 Prometheus是一个监控平台,通过在监控目标上的HTTP端点来收集受监控目标的指标.本指南将向您展示如何使用Pro ...

随机推荐

  1. C++ CGI报“资源访问错误”问题分析

    一线上CGI偶发性会报“资源访问错误”,经过分析得出是因为CgiHost没有读取到CGI的任务输出,即CGI运行完成后连HTTP头都没有一点输出. 然而实际上,不可能没有任何输出,因为CGI至少有无条 ...

  2. 解决栏登 F~~~秋~~~之后只有火狐能上网的问题

    我发现F~~~完秋~~~只有火狐可以上网,惊了,后来发现是没有关代理服雾气 1.打开Chrome->设置 2.翻到最后点击显示高级设置 3.找到网络标签,点击更改代理服务器按钮 4.点击连接标签 ...

  3. centos7.2上安装CDH5.16.2及Spark2【原创】

    背景:我自己的电脑配置太低,想在centos操作系统上安装CDH5.1.2并配置集群,我去阿里云上买了3台按流量计费的阿里云服务器. 大家一定要注意,配置,购买的阿里云服务器不要太低了.建议:3台2核 ...

  4. 《Linux就该这么学》自学笔记_ch22_使用openstack部署云计算服务环境

    <Linux就该这么学>自学笔记_ch22_使用openstackb部署云计算服务环境 文章主要内容: 了解云计算 Openstack项目 服务模块组件详解 安装Openstack软件 使 ...

  5. 关于JavaSE程序的小总结(不分先后顺序 后续继续补充)

    统计字符串中某个字符串出现的次数 package com.jiang.demo01; public class Demo01 { public static void main(String[] ar ...

  6. FPGA 开发板入手途径有哪些呢?

    买到一块 FPGA 开发板,你如何入手呢? 根据博主的经验,你可以通过如下途径来学习: 1.如果你是淘宝上买的,那么可以在淘宝上搜索你的开发板(一般 FPGA 开发板生厂商在淘宝上卖都会附带教程,如米 ...

  7. Centos 使用kubeadm安装Kubernetes 1.15.3

    本来没打算搞这个文章的,第一里面有瑕疵(没搞定的地方),第二在我的Ubuntu 18 Kubernetes集群的安装和部署 以及Helm的安装 也有安装,第三 和社区的问文章比较雷同 https:// ...

  8. 『7.5 NOIP模拟赛题解』

    T1 Gift Description ​ 人生赢家老王在网上认识了一个妹纸,然后妹纸的生日到了,为了表示自己的心 意,他决定送她礼物.可是她喜爱的东西特别多,然而他的钱数有限,因此他想 知道当他花一 ...

  9. FileChannel详解

    经过前两篇文章的学习,相信对Channel有了一定的整体性认识.接下来通过学习本篇文章,更进一步认识Channel,学习FileChannel的细节 用途 特点 api 原理 一.用途 传统IO中的F ...

  10. EF Core 迁移整理

    创建迁移 PowerShell Add-Migration InitialCreate 多数据源 Add-Migration InitialCreate -Context MyDbContext -O ...