美文网首页
centos7部署Prometheus+Grafana脚本

centos7部署Prometheus+Grafana脚本

作者: fanzhouyuanhang | 来源:发表于2021-12-17 16:39 被阅读0次

    #! /bin/bash

    #author fanwenxing 2021-12-14

    #关闭防火墙

    systemctl stop firewalld

    systemctl disable firewalld

    #将安装包下载至服务器的/opt/目录下

    #安装go环境

    #下载go安装包

    wget https://pan.baidu.com/s/1gefGeXmoFmjGxSGxgCuQfw

    #解压安装包

    cd /opt/

    tar -xvf go1.13.1.linux-amd64.tar.gz -C /usr/local/

    #配置环境变量

    echo -e "export GOROOT=/usr/local/go" >> /etc/profile

    echo -e "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile

    source /etc/profile

    go version

    #安装Prometheus环境

    #下载Prometheus安装包

    wget https://github.com/prometheus/prometheus/releases/download/v2.32.0/prometheus-2.32.0.linux-amd64.tar.gz

    #解压安装包

    tar -xvf prometheus-2.32.0.linux-amd64.tar.gz -C /usr/local/

    cd /usr/local

    mv prometheus-2.32.0.linux-amd64/ prometheus

    #启动Prometheus

    #cd prometheus

    #./prometheus --config.file=/usr/local/prometheus/prometheus.yml &

    #配置服务启动

    touch /etc/systemd/system/prometheus.service

    echo -e "[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

    Restart=on-failure

    [Install]

    WantedBy=multi-user.target

    " >> /etc/systemd/system/prometheus.service

    #启动服务,开机启动,检查服务开启状态

    systemctl daemon-reload

    systemctl enable prometheus.service

    systemctl start prometheus.service

    systemctl status prometheus.service

    #验证

    #浏览器打开http://localhost:9090(IP:9090端口)即可打开普罗米修斯自带的监控页面

    #安装Grafana环境

    #下载Grafana安装包

    wget https://dl.grafana.com/oss/release/grafana-8.1.2-1.x86_64.rpm

    cd /opt/

    yum -y localinstall grafana-8.1.2-1.x86_64.rpm

    #启动grafana,设置grafana服务开机自启,并启动服务

    systemctl daemon-reload

    systemctl enable grafana-server.service

    systemctl start grafana-server.service

    #访问grafana

    #浏览器访问http://localhost:3000(IP:3000端口),即可打开grafana页面,默认用户名密码都是admin,初次登录会要求修改默认的登录密码

    #至此Prometheus服务端及Grafana配置完成。

    相关文章

      网友评论

          本文标题:centos7部署Prometheus+Grafana脚本

          本文链接:https://www.haomeiwen.com/subject/cqvifrtx.html