规划:

IP 角色 版本
10.10.0.13 prometheus-server 2.10
10.10.0.11 node_exporter 0.18.1
10.10.0.12 node_exporter 0.18.1

1、下载

官网:https://prometheus.io/download/

[root@prometheus-server ~]# wget https://github.com/prometheus/prometheus/releases/download/v2.10.0/prometheus-2.10.0.linux-amd64.tar.gz

2、创建运行用户

[root@prometheus-server ~]# groupadd -r prometheus
[root@prometheus-server ~]# useradd -r -g prometheus -d / -s /sbin/nologin -c "prometheus user" prometheus

3、安装

安装这里介绍两种方式:

1、docker部署

2、二进制部署 (本文采用)

3.1 二进制部署

[root@prometheus-server ~]# tar -xf prometheus-2.10.0.linux-amd64.tar.gz
[root@prometheus-server ~]# mkdir /etc/prometheus
[root@prometheus-server ~]# mkdir /var/lib/prometheus
[root@prometheus-server ~]# cp prometheus-2.10.0.linux-amd64/prometheus /usr/local/bin/
[root@prometheus-server ~]# cp prometheus-2.10.0.linux-amd64/prometheus.yml /etc/prometheus/
[root@prometheus-server ~]# chown -R prometheus:prometheus /etc/prometheus
[root@prometheus-server ~]# chown -R prometheus:prometheus /var/lib/prometheus/
[root@prometheus-server ~]# vim /usr/lib/systemd/system/prometheus.service
## 配置启动脚本
[Unit]
Description=prometheus
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/bin/prometheus \
 --config.file=/etc/prometheus/prometheus.yml \
 --storage.tsdb.path=/var/lib/prometheus \
 --storage.tsdb.retention=15d \
 --web.read-timeout=5m \
 --web.max-connections=10 \
 --query.max-concurrency=20 \
 --query.timeout=2m \
 --web.enable-lifecycle
Restart=on-failure
[Install]
WantedBy=multi-user.target
## 启动
[root@prometheus-server ~]# systemctl enable prometheus
[root@prometheus-server ~]# systemctl start prometheus
[root@prometheus-server ~]# netstat -anlptu|grep :9090
tcp        0      0 127.0.0.1:39868         127.0.0.1:9090          ESTABLISHED 3080/prometheus    
tcp6       0      0 :::9090                 :::*                    LISTEN      3080/prometheus    
tcp6       0      0 ::1:52200               ::1:9090                ESTABLISHED 3080/prometheus    
tcp6       0      0 127.0.0.1:9090          127.0.0.1:39868         ESTABLISHED 3080/prometheus    
tcp6       0      0 ::1:9090                ::1:52200               ESTABLISHED 3080/prometheus

参数解释:

    --config.file=/etc/prometheus/prometheus.yml       ### prometheus配置文件
     --storage.tsdb.path=/var/lib/prometheus                ### prometheus 存储数据路径
     --storage.tsdb.retention=15d                                 ### prometheus采集数据保留时间
     --web.read-timeout=5m                                         ### 请求链接的最大等待时间           
     --web.max-connections=10                                  ### 最大链接数
     --query.max-concurrency=20                               ### 最大支持的并发查询量
     --query.timeout=2m                                             ### 单个查询超时时间
     --web.enable-lifecycle                                         ### 热加载

3.2 docker部署

官方介绍:https://github.com/prometheus/prometheus/tree/master

docker方式部署需要先创建prometheus.yml文件

[root@prometheus-server ~]# mkdir /opt/prometheus/
[root@prometheus-server ~]# vim /opt/prometheus/prometheus.yml
# my global config
global:
  scrape_interval:     15s # 抓取数据的周期,默认为1min 
  evaluation_interval: 15s # 更新rules文件的周期,默认为1min
  # scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
    - targets: ['localhost:9090']
## 运行
[root@prometheus-server ~]# docker run -d -p : --user="root" --name prometheus -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml -v /opt/prometheus/data:/prometheus prom/prometheus

说明:

  1、--user:指定运行用户

  2、需要宿主机创建prometheus.yml配置文件

3、浏览器访问

启动后,直接浏览器访问端口9090

这样,prometheus服务就安装好了。

Prometheus入门到放弃(1)之Prometheus安装部署的更多相关文章

  1. Prometheus入门到放弃(2)之Node_export安装部署

    1.下载安装 node_exporter服务需要在三台机器都安装,这里我们以一台机器为例: 地址:https://prometheus.io/download/ ### 另外两个节点部署时,需要先创建 ...

  2. Prometheus入门到放弃(5)之AlertManager部署

    alertmanager与exporters.cadvisor一样,都是独立于prometheus项目,这里我们也使用docker方式部署alertmanager. 1.下载镜像 镜像地址:https ...

  3. 《区块链:从入门到放弃》之obc安装步骤

    obc安装步骤 朋友们可能会好奇,厨师不研究菜谱怎么改研究兵法了,哈哈,我原本是app出身,最近被安排去预研区块链和比特币技术,2个月下来,颇有斩获.期间得到IBM的CC同学指导我一步一步安装obc的 ...

  4. Kubernetes入门(一)——Kubernetes v1.18.5 安装部署

    Kubernetes的安装有两种方式:一是使用各个厂商封装的Kubernetes发行版,优点是可以一键安装部署,操作简单,缺点也很明显,若安装过程中某一步骤出现问题,很难定位处理:二是使用官方提供的k ...

  5. Hadoop入门进阶课程13--Chukwa介绍与安装部署

    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,博主为石山园,博客地址为 http://www.cnblogs.com/shishanyuan  ...

  6. Apache入门篇(一)之安装部署apache

    一.HTTPD特性 (1)高度模块化:core(核心) + modules(模块) = apache(2)动态模块加载DSO机制: Dynamic Shared Object(动态共享对象)(3)MP ...

  7. Prometheus入门到放弃(7)之redis_exporter部署

    redis监控,prometheus需要使用redis_exporter客户端. 这里我们采用docker方式部署,既可以部署在redis所在服务器,也可以部署在其他机器: docker镜像地址:ht ...

  8. Prometheus入门到放弃(6)之AlertManager进阶

    前面几个篇幅,我们介绍了alertmanger报警配置,在实际运维过程中,我们都会遇到,报警的重复发送,以及报警信息关联性报警.接下来我们就介绍下通过alertmanger对告警信息的收敛.一.告警分 ...

  9. Prometheus入门到放弃(4)之cadvisor监控docker容器

    Prometheus监控docker容器运行状态,我们用到cadvisor服务,cadvisor我们这里也采用docker方式直接运行. 1.下载镜像 [root@prometheus-server ...

随机推荐

  1. Codeforces 1264C/1265E Beautiful Mirrors with queries (概率期望、DP)

    题目链接 http://codeforces.com/contest/1264/problem/C 题解 吐槽:为什么我赛后看cf的题就经常1h内做出Div.1 C, 一打cf就动不动AB题不会啊-- ...

  2. OSPF区域间+NAT详解

  3. css中的浮动与定位

    传送门:https://www.cnblogs.com/junwuyao/p/7435257.html

  4. H5注意点(1)

    H1标签在企业开发中,每一个页面至多只能有一个H1标签,被H1标签包裹的是整个页面最重要的信息. img标签,格式:<img src=" ">,当中src就是用来告诉i ...

  5. 右键查看别人网页的js代码为什么会显示乱码

    查看别人网页的js显示乱码 解决方法: 打开浏览器,选择设置,点击更多,选择文字编码为Unicode

  6. 【django学习】request.POST与request.POST.get两者主要区别

    本文链接:https://blog.csdn.net/xun527/article/details/87777576request.POST是用来接收前端传过来的数据 一.request.POST.g ...

  7. sass - for循环写法

    如要设置多个li的动画延迟时间时 注:这里选择器要加#{}才行 不然就会编译成: 6.7. 插值语句 #{} (Interpolation: #{}) 通过 #{} 插值语句可以在选择器或属性名中使用 ...

  8. [转载]IBM公司发布了最新的power7服务器p750 p770 p780

    [转载]IBM公司发布了最新的power7服务器p750 p770 p780 (2015-06-11 12:54:17) 转载▼ http://blog.sina.com.cn/s/blog_6f52 ...

  9. ISO/IEC 9899:2011 条款5——5.1 概念模型

    5.1 概念模型 5.1.1 翻译环境 5.1.2 执行环境

  10. PLSQL流函数代码 540页 【我】

    540页 流函数代码 -- Create table create table STOCKTABLE ( TICKER ), TRADE_DATE DATE, OPEN_PRICE NUMBER, C ...