• Prometheus监控系统(一)安装


    prometheus是一个用Go编写的时序数据库,可以支持多种语言客户端

    安装步骤:

      1)安装go 语言环境

      2)在监控服务器上安装prometheus

      3)被监控端安装 exporter

      4)安装grafana

    服务端安装:

      1、go语言环境配置

    ~]# wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
    ~]# tar xf go1.8.3.linux-amd64.tar.gz -C /usr/local/
    ~]# echo export PATH=$PATH:/usr/local/go/bin >>/etc/profile
    ~]# . /etc/profile
    ~]# go version
    go version go1.8.3 linux/amd64

      2、安装Prometheus

        官网下载对应系统的版本:https://prometheus.io/download/

    ~]# wget https://github.com/prometheus/prometheus/releases/download/v2.25.0/prometheus-2.25.0.linux-amd64.tar.gz
    ~]# tar xf prometheus-2.25.0.linux-amd64.tar.gz -C /usr/local/
    local]# ln -s prometheus-2.25.0.linux-amd64 prometheus

        修改配置文件 prometheus.yml 如下图:

      scrape_configs: 采集信息配置,一个job_name下也可配置多个targets

      配置完之后后台运行,运行命令后加&就可以

      # ./prometheus &

      浏览器访问,默认监听9090端口

      3、被监控端安装node_exporter(默认系统监控项),可以根据监控需求安装相对应得exporter

       官网下载安装包:https://prometheus.io/download/

    ~]# tar xf node_exporter-1.1.2.linux-amd64.tar.gz -C /usr/local/
    ~]# /usr/local/node_exporter-1.1.2.linux-amd64/node_exporter &
    ~]# netstat -anpt |grep :9100
    tcp6       0      0 :::9100                 :::*                    LISTEN      38922/node_exporter 
    tcp6       0      0 192.168.53.8:9100       192.168.53.6:56228      ESTABLISHED 38922/node_exporter

    监控目标主机状态为UP

            配置开机自启

    ]# vim /etc/systemd/system/prometheus.service
    
    [Unit]
    Description=Prometheus Monitoring System
    Documentation=Prometheus Monitoring System
     
    [Service]
    ExecStart=/usr/local/prometheus/prometheus 
      --config.file=/usr/local/prometheus/prometheus.yml  
      --web.listen-address=:9090
     
    [Install]
    WantedBy=multi-user.target
    
    ]# systemctl daemon-reload
    ]# systemctl start promethues
    ]# systemctl enable prometheus.service 
    Created symlink from /etc/systemd/system/multi-user.target.wants/prometheus.service to /etc/systemd/system/prometheus.service.

      4、安装grafana,默认得Prometheus页面没有那么直观,安装grafana是为了页面显示更加直观

    ~]# wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.3-1.x86_64.rpm
    ~]# yum localinstall grafana-5.2.3-1.x86_64.rpm
    ~]# systemctl start grafana-server.service
    ~]# netstat -anpt |grep :3000
    tcp6       0      0 :::3000                 :::*                    LISTEN      7509/grafana-server

    浏览器访问grafana 默认端口 3000

    输入默认账号密码 admin/admin,而后提示更新密码

    添加Data Sources,新增 

    选择Prometheus 2.0 Stats,保存

    最终效果如下:

  • 相关阅读:
    iOS开发>学无止境
    iOS开发>学无止境
    Review1(C#语言基础)
    Lua
    c#笔记(四)——switch
    鼠标拖拽物体
    lua-路径加载lua文件-函数返回值,访问lua文件中的变量
    lua-1-c# 执行lua文件-调用lua文件中的方法
    Unity实现手机录音功能
    lua-table类的继承
  • 原文地址:https://www.cnblogs.com/goujinyang/p/14495534.html
Copyright © 2020-2023  润新知