二进制安装prometheus

Camellia 发布于 2024-05-13 369 次阅读


AI 摘要

您可以按照以下步骤进行二进制安装 Prometheus。 首先下载 Prometheus 的最新版本(示例中为 v2.29.1),然后解压到指定目录: ```bash mkdir /opt/app tar xvf prometheus-2.29.1.linux-amd64.tar.gz -C /opt/app mv /opt/app/prometheus-2.29.1.linux-amd64 /opt/app/prometheus ``` 接下来,准备并配置 service 文件以启动 Prometheus 服务: ```bash cat <<-EOF > /etc/systemd/system/prometheus.service [Unit] Description="prometheus" Documentation=https://prometheus.io/ After=network.target [Service] Type=simple ExecStart=/opt/app/prometheus/prometheus --config.file=/opt/app/prometheus/prometheus.yml --storage.tsdb.path=/opt/app/prometheus/data --web.enable-lifecycle Restart=on-failure RestartSecs=5s SuccessExitStatus=0 LimitNOFILE=655360 StandardOutput=syslog StandardError=syslog SyslogIdentifier=prometheus [Install] WantedBy=multi-user.target EOF ``` 最后,启动 Prometheus 服务并检查服务状态: ```bash systemctl daemon-reload systemctl restart prometheus systemctl status prometheus ``` 同时,您可以使用以下命令检查 Prometheus 服务的端口、进程和日志: ```bash ss -ntlp |grep 9090 ps -ef |grep prometheus |grep -v grep tail -100 /var/log/messages |grep prometheus ```

二进制安装prometheus

下载prometheus

解压到指定目录

mkdir /opt/app
tar xvf prometheus-2.29.1.linux-amd64.tar.gz -C /opt/app

mv /opt/app/prometheus-2.29.1.linux-amd64 /opt/app/prometheus

准备service文件

cat <<-"EOF" > /etc/systemd/system/prometheus.service
[Unit]
Description="prometheus"
Documentation=https://prometheus.io/
After=network.target

[Service]
Type=simple
ExecStart=/opt/app/prometheus/prometheus  --config.file=/opt/app/prometheus/prometheus.yml --storage.tsdb.path=/opt/app/prometheus/data --web.enable-lifecycle

Restart=on-failure
RestartSecs=5s
SuccessExitStatus=0
LimitNOFILE=655360
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=prometheus

[Install]
WantedBy=multi-user.target
EOF

启动prometheus 服务

systemctl daemon-reload
systemctl restart prometheus
systemctl status prometheus

检查prometheus服务

# 查看端口 进程 日志
ss -ntlp |grep 9090
ps -ef |grep prometheus |grep -v grep 

tail -100  /var/log/messages |grep prometheus