二进制安装prometheus

Sakura 发布于 2024-05-13 615 次阅读


AI 摘要

二进制安装Prometheus的步骤如下: 1. 下载Prometheus并解压到指定目录: ```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 ``` 2. 准备service文件: 创建并编辑文件`/etc/systemd/system/prometheus.service`,内容包括服务描述、启动指令和日志配置等。 3. 启动Prometheus服务: 执行以下命令以重载系统守护进程并启动服务: ```bash systemctl daemon-reload systemctl restart prometheus systemctl status prometheus ``` 4. 检查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 # 表示启用热加载配置 curl -X POST 127.0.0.1:9090/-/reload 可能会有安全问题

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