本文采用二进制源码安装方式,安装环境如下
操作系统 | Grafana版本 | Prometheus版本 |
---|---|---|
Alibaba Cloud Linux 3 | 8.5.4 | 2.36.0 |
release地址:https://github.com/prometheus/prometheus/releases
#下载Prometheus二进制包
wget https://ghproxy.com/https://github.com/prometheus/prometheus/releases/download/v2.36.0/prometheus-2.36.0.linux-amd64.tar.gz
tar xf prometheus-2.36.0.linux-amd64.tar.gz -C /opt/
mv /opt/prometheus-2.36.0.linux-amd64 /opt/prometheus
#将prometheus添加至systemd管理
cat << eof >> /etc/systemd/system/prometheus.service
[Unit]
Description=logging prometheus service
Documentation=https://prometheus.io
[Service]
Type=simple
User=root
Group=root
ExecStart=/opt/prometheus/prometheus --web.enable-lifecycle --config.file=/opt/prometheus/prometheus.yml
Restart=on-failure
[Install]
WantedBy=multi-user.target
eof
systemctl daemon-reload
systemctl start prometheus.service
systemctl enable prometheus.service
官方release:https://grafana.com/grafana/download
wget https://dl.grafana.com/oss/release/grafana-8.5.4.linux-amd64.tar.gz
tar -zxvf grafana-8.5.4.linux-amd64.tar.gz -C /opt/
mv /opt/ grafana-8.5.4/ /opt/grafana
mkdir /opt/grafana/data
sed -i 's/data\/plugins/plugins-bundled/g' /opt/grafana/conf/defaults.ini
#将grafana添加至systemd管理
cat << eof >> /etc/systemd/system/grafana.service
[Unit]
Description=logging Grafana service
Documentation=https://grafana.com/
[Service]
Type=simple
User=root
Group=root
ExecStart=/opt/grafana/bin/grafana-server --homepath /opt/grafana/ web
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
eof
systemctl daemon-reload
systemctl start grafana.service
systemctl enable grafana.service