prometheus+granfana监控部署(二进制)

  1. prometheus搭建

    prometheus官网下载地址:Download | Prometheus

    #下载截止2021/9/9最新版本
    wget https://github.com/prometheus/prometheus/releases/download/v2.29.2/prometheus-2.29.2.linux-amd64.tar.gz
    
    #创建prometheus目录
    mkdir -p /opt/monitor
    
    #解压移动
    tar -xf prometheus-2.29.2.linux-amd64.tar.gz
    mv prometheus-2.29.2.linux-amd64 /opt/monitor/prometheus
    
    #添加systemctl管理
    vi /usr/lib/systemd/system/prometheus.service
    [Unit]
    Description=prometheus
    [Service]
    ExecStart=/opt/monitor/prometheus/prometheus --config.file=/opt/monitor/prometheus/prometheus.yml
    ExecReload=/bin/kill -HUP $MAINPID
    KillMode=process
    Restart=on-failure
    [Install]
    WantedBy=multi-user.target
    
    #启动prometheus
    systemctl daemon-reload 
    systemctl start prometheus.service 
    systemctl status prometheus.service
    
  2. granfana搭建

    granfana官网下载地址:Download Grafana | Grafana Labs

    #下载截止2021/9/9最新版本
    wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.1.2.linux-amd64.tar.gz
    tar -zxvf grafana-enterprise-8.1.2.linux-amd64.tar.gz
    mkdir /opt/monitor/grafana
    mv grafana-8.1.2 /opt/monitor/grafana
    
    vi /usr/lib/systemd/system/grafana.service
    [Unit]
    Description=grafana
    [Service]
    ExecStart=/opt/monitor/grafana/bin/grafana-server -homepath=/opt/monitor/grafana
    ExecReload=/bin/kill -HUP $MAINPID
    KillMode=process
    Restart=on-failure
    [Install]
    WantedBy=multi-user.target
    
    systemctl daemon-reload 
    systemctl start grafana.service
    systemctl status grafana.service 
    
  3. node_exporter:用于监控Linux系统的指标采集器

    prometheus采集器地址:Exporters and integrations | Prometheus

    #注:如果github拉取较慢,可采用迅雷下载上传
    wget https://github.com/prometheus/node_exporter/releases/download/v1.2.2/node_exporter-1.2.2.linux-amd64.tar.gz
    
    tar  -xf node_exporter-1.2.2.linux-amd64.tar.gz 
    mv node_exporter-1.2.2.linux-amd64 /usr/local/node_exporter
    
    vi /usr/lib/systemd/system/node_exporter.service
    [Unit]
    Description=node_exporter
    [Service]
    ExecStart=/usr/local/node_exporter/node_exporter
    #ExecStart=/usr/local/node_exporter/node_exporter --web.config=/usr/local/node_exporter/config.yml
    ExecReload=/bin/kill -HUP $MAINPID
    KillMode=process
    Restart=on-failure
    [Install]
    WantedBy=multi-user.target
    
    systemctl daemon-reload 
    systemctl start node_exporter.service 
    systemctl status node_exporter.service 
    
  4. 配置prometheus进行发现

    #末尾添加配置,ip地址为安装node_exporter的地址
    vim /opt/monitor/prometheus/prometheus.yml
    - job_name: "node"
        static_configs:
          - targets: ["192.168.123.97:9100"]
    #prometheus支持热加载配置文件
    kill -HUP prometheus的PID
    
  5. 访问prometheus的ip:9090查看

    点击Status ----> Targets 查看

    prometheus+granfana监控部署(二进制)

  6. 登陆granfana页面ip:3000

    默认密码admin admin 初次登陆需要修改密码

    点击左侧设置 ----> Data sources

    prometheus+granfana监控部署(二进制)

    最下方测试保存

  7. 添加监控模板

    prometheus+granfana监控部署(二进制)

    点击import完成后,填入9276 点击load

    然后在import上边选择 之前添加的数据库后 再点击import

  8. 效果如图

    prometheus+granfana监控部署(二进制)

上一篇:Prometheus监控系统


下一篇:prometheus 监控的部署