• CentOS7安装Prometheus(二进制)


    一、概述

    Prometheus是由SoundCloud开发的开源监控报警系统和时序列数据库(TSDB)。Prometheus使用Go语言开发,是Google BorgMon监控系统的开源版本。

    环境说明

    操作系统:centos 7.6
    ip地址:192.168.31.150

    下载包

    https://prometheus.io/download/
    目前最新版是:2.14.0
    下载链接:
    https://github.com/prometheus/prometheus/releases/download/v2.14.0/prometheus-2.14.0.linux-amd64.tar.gz

    二、安装

    useradd prometheus -s /sbin/nologin
    tar zxvf prometheus-2.14.0.linux-amd64.tar.gz -C /data
    mv /data/prometheus-2.14.0.linux-amd64 /data/prometheus
    chown prometheus:prometheus -R /data/prometheus

    封装service

    vi /etc/systemd/system/prometheus.service

    内容如下:

    [Unit]
    Description=Prometheus
    After=network.target
    [Service]
    ExecStart=/data/prometheus/prometheus --config.file=/data/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus/data
    User=prometheus
    [Install]
    WantedBy=multi-user.target

    注意:主要修改ExecStart和User

    设置开机自启动

    systemctl daemon-reload
    systemctl enable prometheus
    systemctl start prometheus

    查看端口

    # ss -tunlp|grep prometheus
    tcp    LISTEN     0      128      :::9090                 :::*                   users:(("prometheus",pid=969,fd=5))

    如果是centos 6.x系统,需要自己写一个启动脚本。

    vi /etc/init.d/prometheus

    内容如下:

    #!/bin/bash
    # auditd        Start jar package
    # chkconfig: 2345 14 87
    # description: This is admin project
    #define var
    PROJECT_SERVICE="prometheus"
    PORT="9090"
    . /etc/init.d/functions 
    export START="nohup /data/prometheus/prometheus --config.file=/data/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus/data &"
    #服务脚本
    start(){
        echo "${PROJECT_SERVICE} starting....."
        cd /data/${PROJECT_SERVICE} && eval $START
        if [ $? -eq 0 ];then
                action "$PROJECT_SERVICE is starting" /bin/true
        else
                action "$PROJECT_SERVICE is starting" /bin/false
        fi
    }
    stop(){
        kill -9 `lsof -t -i:${PORT}`
        if [ $? -eq 0 ];then
            action "$PROJECT_SERVICE is stoping" /bin/true
        else
            action "$PROJECT_SERVICE is stoping" /bin/false
        fi 
    }
    status(){
        if [ `ss -tunlp|grep ${PROJECT_SERVICE}|awk '{print $5}'|cut -d: -f4` = ${PORT} ];then
                echo "${PROJECT_SERVICE} is running....."
        else
                echo "${PROJECT_SERVICE} is stopping....."
        fi
    }
    case $1 in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        start
        ;;
    status)
        status
        ;;
    *)
       echo "$0 <start|stop|restart>"
    esac
    View Code

    添加权限,并启动

    chmod 755 /etc/init.d/prometheus
    /etc/init.d/prometheus start

    三、访问页面

    访问targets
    http://192.168.31.150:9090/targets

    到这里,安装就结束了。

  • 相关阅读:
    Ajax
    事件委托
    事件对象
    js的基础类型与引用类型
    Javascript和HTML dom
    用jQuery写的最简单的表单验证
    初学HTML5的一点理解
    CMake 入门
    centos7上rpm安装wkhtmltopdf
    centos7 下安装思源黑体字体
  • 原文地址:https://www.cnblogs.com/xiao987334176/p/11927979.html
Copyright © 2020-2023  润新知