1. 程式人生 > 其它 >一鍵部署prometheus和granfana

一鍵部署prometheus和granfana

一鍵部署prometheus和granfana

 基於shell指令碼進行二進位制安裝prometheus和grafana

#cat prometheus_grafana.sh
#!/bin/bash
#********************************************************************
#Author:        wei
#********************************************************************
. /etc/rc.d/init.d/functions
set -e

Useradd () {
useradd  
-s /sbin/nologin -M prometheus } Package_install () { #準備prometheus-2.23.0.linux-amd64.tar.gz 和 grafana-enterprise-7.3.2.linux-amd64.tar.gz [ -f ./prometheus-2.23.0.linux-amd64.tar.gz ] || wget https://github.com/prometheus/prometheus/archive/refs/tags/v2.23.0.tar.gz [ -f ./grafana-enterprise-7.3.2.linux-amd64.tar.gz ] || wget https://
dl.grafana.com/enterprise/release/grafana-enterprise-7.3.2.linux-amd64.tar.gz tar xvf prometheus-2.23.0.linux-amd64.tar.gz -C /data chown -R prometheus:prometheus /data/prometheus-2.23.0.linux-amd64 echo 'export PATH=/data/prometheus-2.23.0.linux-amd64:$PATH' >> /etc/profile && source /etc/profile cat
> /usr/lib/systemd/system/prometheus.service <<EOF [Unit] Description=Prometheus Documentation=https://prometheus.io/ After=network.target [Service] Type=simple User=prometheus ExecStart=/data/prometheus-2.23.0.linux-amd64/prometheus --config.file=/data/prometheus-2.23.0.linux-amd64/prometheus.yml --storage.tsdb.path=/data/prometheus-2.23.0.linux-amd64/data Restart=on-failure [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl restart prometheus systemctl enable prometheus tar -xvf grafana-enterprise-7.3.2.linux-amd64.tar.gz -C /data cat > /usr/lib/systemd/system/grafana-server.service <<EOF [Unit] Description=Grafana After=network.target [Service] Type=notify ExecStart=/data/grafana-7.3.2/bin/grafana-server -homepath /data/grafana-7.3.2 Restart=on-failure [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl start grafana-server systemctl enable grafana-server } Useradd Package_install && action "prometheus grafana 安裝成功"

訪問驗證

瀏覽器訪問IP:port

 

 

 

官方連結

https://prometheus.io/download/

https://grafana.com/grafana/download