# 创建 prometheus 用户
# -M 不创建家目录
# -s 使用指定的 shell,这里禁止登录
useradd -M -s /usr/sbin/nologin prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.45.2/prometheus-2.45.2.linux-amd64.tar.gz
tar xfv prometheus-2.45.2.linux-amd64.tar.gz
mkdir /opt/prometheus/
mv prometheus-2.45.2.linux-amd64 /opt/prometheus/prometheus
chown -R prometheus:prometheus /opt/prometheus/prometheus
vim /etc/systemd/system/prometheus.service
[Unit]
Description=PrometheusServer
After=network-online.target
[Service]
Type=simple
User=prometheus
Group=prometheus
Restart=on-failure
ExecStart=/opt/prometheus/prometheus/prometheus \
--config.file=/opt/prometheus/prometheus/prometheus.yml \
--storage.tsdb.path=/opt/prometheus/prometheus/data \
--storage.tsdb.retention.time=60d \
--web.enable-lifecycle
[Install]
WantedBy=multi-user.target
systemctl status prometheus
查看状态
systemctl enable prometheus
开机自启
http://localhost:9090
http://localhost:9093
http://localhost:3000
http://localhost:9100/