JiaHe

相遇即是缘

Prometheus

手动安装

# 官方下载地址:https://prometheus.io/download
tar -zxf prometheus-2.54.1.linux-amd64.tar.gz -C /opt
mv /opt/prometheus-2.54.1.linux-amd64 /opt/prometheus
ln -s /opt/prometheus/prometheus /usr/local/bin/prometheus

# 配置服务
cat > /usr/lib/systemd/system/prometheus.service <<EOF
[Unit]
Description=prometheus
After=network.target

[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/prometheus --config.file="/opt/prometheus/prometheus.yml" --storage.tsdb.path="/opt/prometheus/data/" --web.enable-lifecycle --storage.tsdb.retention.time=15d
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus
systemctl status prometheus

Docker安装

mkdir -p /opt/prometheus/{conf,data}

touch /opt/prometheus/conf/prometheus.yml
/opt/docker-compose.yml
versin: "3.0"
services:
prometheus:
image: prom/prometheus
restart: always
volumes:
- ./prometheus/conf/prometheus.yml:/etc/prometheus/prometheus.yml
- ./prometheus/data:/prometheus
ports:
- "9090:9090"
user: root

Grafana安装

手动安装

# https://grafana.com/grafana/download
sudo yum install -y https://dl.grafana.com/enterprise/release/grafana-enterprise-11.2.2-1.x86_64.rpm
systemctl start grafana-server.service
systemctl enable grafana-server.service
systemctl status grafana-server.service

# 访问 http://ip:3000
# 默认用户名admin 密码admin

Docker安装

mkdir -p /opt/grafana
/opt/docker-compose.yml
versin: "3.0"
services:
grafana:
image: grafana/grafana:latest
restart: always
volumes:
- ./grafana:/var/lib/grafana
ports:
- "3000:3000"
user: root