*Prometheus* 是一个开源的服务监控系统和时间序列数据库

官方网站:prometheus.io

一、安装prometheus

cd /usr/local/        #进入安装目录

wget https://github.com/prometheus/prometheus/releases/download/v2.27.1/prometheus-2.27.1.linux-amd64.tar.gz        #wget下载prometheus安装包

tar xf prometheus-2.27.1.linux-amd64.tar.gz        #解压

ln -s prometheus-2.27.1.linux-amd64 prometheus        #建立软链接

chown -R root.root prometheus-2.27.1.linux-amd64        #授予root权限

普罗米修斯默认前台启动,构建启动脚本完成后台启动:
vim /lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus server daemon
After=network.target

[Service]
Type=simple
User=root
Group=root
ExecStart="/usr/local/prometheus/prometheus" --config.file="/usr/local/prometheus/prometheus.yml" --storage.tsdb.path="/usr/local/prometheus/data" --storage.tsdb.retention=5d --web.console.
templates="/usr/local/prometheus/consoles" --web.console.libraries="/usr/local/prometheus/console_libraries" --web.max-connections=512 --web.external-url="http://192.168.149.133:9090" --web.listen-address="0.0.0.0:9090"Restart=on-failure

[Install]
WantedBy=multi-user.target

systemctl daemon-reload
systemctl restart prometheus.service
systemctl status prometheus.service
启动完成可访问页面 默认为9090端口

二、添加监控服务器选项(监控主机)

在配置文件中加入监控配置信息,比如要监控xxx.xxx.xxx.134服务器,如下配置

在xxx.xxx.xxx.134安装node_exporter插件,在普罗米修斯官网就可下载

xxx.xxx.xxx.134主机进行以下操作:
cd /usr/local        #进入安装插件目录

wget https://github.com/prometheus/node_exporter/releases/download/v1.1.2/node_exporter-1.1.2.linux-amd64.tar.gz        #wget下载插件安装包

tar xf node_exporter-1.1.2.linux-amd64.tar.gz        #解压

ln -s node_exporter-1.1.2.linux-amd64 node_exporter        #建立软连接

chown -R root.root node_exporter-1.1.2.linux-amd64        #授予root权限

构建node_exporter后台启动脚本:
vim /lib/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/node_exporter/node_exporter \
--collector.mountstats \
--collector.systemd \
--collector.ntp \
--collector.tcpstat
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=2s
Restart=always

[Install]
WantedBy=multi-user.target

systemctl daemon-reload                #加载配置文件
systemctl start node_exporter.service        #启动node插件
systemctl status node_exporter.service      #查看运行状态

回到普罗米修斯主机,修改配置文件(只修改以下蓝色部分内容):
vim /usr/local/prometheus/prometheus.yml

......
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']

- job_name: 'node_exporter'
   metrics_path '/metrics'
   static_configs:
    - targets: 
      - 'xxx.xxx.xxx.134:9100'
......

systemctl daemon-reload
systemctl restart prometheus.service
重启完成可访问页面查看

三、添加监控应用级选项(监控各种应用,以mysql为例)

在配置文件中加入监控配置信息,比如要监控xxx.xxx.xxx.135服务器上的mysql,如下配置

在xxx.xxx.xxx.135安装mysqld_exporter插件,在普罗米修斯官网就可下载

在xxx.xxx.xxx.135主机操作:
cd /usr/local

wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.13.0/mysqld_exporter-0.13.0.linux-amd64.tar.gz

tar xf mysqld_exporter-0.13.0.linux-amd64.tar.gz

ln -s mysqld_exporter-0.13.0.linux-amd64 mysqld_exporter

chown -R root.root mysqld_exporter-0.13.0.linux-amd64

构建mysqld_exporter后台启动脚本:
vim /lib/systemd/system/mysqld_exporter.service
[Unit]
Description=Prometheus MySQL Exporter
After=network.target

[Service]
Type=simple
Restart=always
User=root
Group=root
ExecStart=/usr/local/mysqld/mysqld_exporter --config.my-cnf=/usr/local/mysqld/mysqld_exporter.cnf --collect.global_status --collect.auto_increment.columns --collect.info_schema.processlist --collect.binlog_size
 --collect.info_schema.tablestats --collect.global_variables --collect.info_schema.innodb_metrics --collect.info_schema.query_response_time --collect.info_schema.userstats --collect.info_schema.tables --collect.perf_schema.tablelocks --collect.perf_schema.file_events --collect.perf_schema.eventswaits --collect.perf_schema.indexiowaits --collect.perf_schema.tableiowaits --collect.slave_status --web.listen-address=0.0.0.0:9104
[Install]
WantedBy=multi-user.target

创建mysql进入启动配置文件(同时确保mysql数据库有root用户并授权了远程可登录):
vim /usr/local/mysqld_exporter/mysqld_exporter.cnf
[client]
user=root
password=123456

检测mysql配置文件是否正确:
./mysqld_exporter --config.my-cnf="./mysqld_exporter.cnf"

systemctl daemon-reload        #加载配置
systemctl start mysqld_exporter        #启动mysqld监控插件

回到普罗米修斯主机,修改配置文件:
vim /usr/local/prometheus/prometheus.yml

......
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']

- job_name: 'node_exporter'
   metrics_path '/metrics'
   static_configs:
    - targets: 
      - 'xxx.xxx.xxx.134:9100'

- job_name: 'mysqld_exporter'
   metrics_path '/metrics'
   static_configs:
    - targets: 
      - 'xxx.xxx.xxx.135:9104'
  
......

systemctl daemon-reload                #加载配置
systemctl restart prometheus.service        #重启prometheus服务

访问xxx.xxx.xxx.xxx:9090就可看到主机级和mysql的监控情况

注意:各类监控服务配置和上面配置大同小异,各类监控服务插件在prometheus官网就可直接下载使用:https://prometheus.io/

普罗米修斯!Ubuntu下prometheus监控软件安装使用的更多相关文章

  1. 一步步教你用Prometheus搭建实时监控系统系列(一)——上帝之火,普罗米修斯的崛起

    上帝之火 本系列讲述的是开源实时监控告警解决方案Prometheus,这个单词很牛逼.每次我都能联想到带来上帝之火的希腊之神,普罗米修斯.而这个开源的logo也是火,个人挺喜欢这个logo的设计. 本 ...

  2. Prometheus普罗米修斯快速入门

    欢迎来到普罗米修斯! Prometheus是一个监控平台,通过从监控目标的抓取HTTP端点上获取指标. 本指南将展示如何使用和安装Promethues,配置和监视第一个资源.还将下载并安装导出器Exp ...

  3. 普罗米修斯Prometheus监控安装

    普罗米修斯Prometheus监控安装 架构: 服务端:192.168.0.204 客户端:192.168.0.206 环境准备:所有节点安装go 语言环境 rz go1.12.linux-amd64 ...

  4. 监控神器-普罗米修斯Prometheus的安装

    搬砖党的福音:普罗米修斯-监控神器 功能: 在业务层用作埋点系统 Prometheus支持多种语言(Go,java,python,ruby官方提供客户端,其他语言有第三方开源客户端).我们可以通过客户 ...

  5. 在Grafana使用普罗米修斯

    aaarticlea/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IE ...

  6. 记录一次k8s环境尝试过程(初始方案,现在已经做过很多完善,例如普罗米修斯)

    记录一次Team k8s环境搭建过程(初始方案,现在已经做过很多完善,例如普罗米修斯) span::selection, .CodeMirror-line > span > span::s ...

  7. (2012年旧文)纪念史蒂夫乔布斯---IT界的普罗米修斯

    谈苹果与乔布斯系列一  IT界的普罗米修斯 纪念PC界的先驱 史蒂夫乔布斯 2012-4-5 清明节,纪念IT时代的开创人—伟大的史蒂夫 乔布斯. 没有乔布斯,计算机还是属于一群科技人士的工具,没有漂 ...

  8. 当ABAP遇见普罗米修斯

    Jerry每次在工作场合中同Prometheus(普罗米修斯)打交道时,都会"出戏",因为这个单词给我的第一印象,并不是用go语言实现的微服务监控利器,而是名导雷德利·斯科特(Ri ...

  9. 普罗米修斯+grafana监控k8s

    其实现原理有点类似ELK.node-exporter组件负责收集节点上的metrics监控数据,并将数据推送给prometheus, prometheus负责存储这些数据,grafana将这些数据通过 ...

随机推荐

  1. 台式机ATX电源:各接口定义、启动方法、电源特点

    ATX,英文全称:Advanced Technology Extended,是一种由Intel公司在1995年公布的PC机主板结构规范. ATX电源作用是把交流220V的电源转换为计算机内部使用的直流 ...

  2. path()的name属性,有什么用?

    官网(参考:命名 URL 模式) 命名 URL 模式: 为了完成反向解析 URL ,你需要像上面那样使用 命名 URL 模式 .用于命名 URL 的字符串可以包含任意字符,并不仅限于 Python 里 ...

  3. 22.1.23Manacher算法、双端队列、单调栈

    22.1.23Manacher算法.双端队列.单调栈 1.Manacher算法 1)用途: Manacher算法用于解决类似求某个字符串中最长的回文子串.(回文就是正着读和倒着读一样的结构). 2)算 ...

  4. display 不同的值及他们的作用

    display 不同的值及他们的作用 常见 block 块元素类型,默认宽度为父元素宽度,可设置宽高,并独占一行 none 元素不显示,并从文档流中移除 inline 行内元素类型,默认宽度为内容宽度 ...

  5. 【技术干货】华为云FusionInsight MRS的自研超级调度器Superior Scheduler

    Superior Scheduler是一个专门为Hadoop YARN分布式资源管理系统设计的调度引擎,是针对企业客户融合资源池,多租户的业务诉求而设计的高性能企业级调度器. Superior Sch ...

  6. redis 持久化有几种方式?

    面试题 redis 的持久化有哪几种方式?不同的持久化机制都有什么优缺点?持久化机制具体底层是如何实现的? 面试官心理分析 redis 如果仅仅只是将数据缓存在内存里面,如果 redis 宕机了再重启 ...

  7. 部署新项目自动对数据库进行migrate和让用户收到创建用户/超级用户信息

    当项目中的models有数据表的时候,普通做法是用docke exec -it hello_web_1 bash,进入容器进行migrate,但是我们想要容器一启动就自动创建数据表,可以修改docke ...

  8. Dubbo 如何停机?

    Dubbo 是通过 JDK 的 ShutdownHook 来完成优雅停机的,所以如果使用 kill -9 PID 等强制关闭指令,是不会执行优雅停机的,只有通过 kill PID 时,才 会执行.

  9. 百度移动统计调用api教程,少进坑(82001错误)

    相信很多小伙伴使用了百度统计,来查看自己应用使用的情况,但是会发现百度移动统计在官网没有api调用取数据的接口, 现在我就以自己成功调用api并且成功拿到数据,将这个步骤给大家参考,(末尾有调用移动统 ...

  10. Netty学习摘记 —— 深入了解Netty核心组件

    本文参考 本篇文章是对<Netty In Action>一书第三章"Netty的组件和设计"的学习摘记,主要内容为Channel.EventLoop.ChannelFu ...