发布于2026-07-12 阅读(0)
扫一扫,手机访问

uname -m,如果返回的是 【aarch64】,那就老老实实下载 linux-arm64.tar.gz 包;如果是 x86_64,则去拿 linux-amd64.tar.gz。选错了会直接报错“cannot execute binary file”,这个错很直接,不用怀疑人生。
Prometheus 的官方 Release 页面上有各版本下载,比如 v2.49.1 的 ARM64 包地址就是这个:
wget https://github.com/prometheus/prometheus/releases/download/v2.49.1/prometheus-2.49.1.linux-arm64.tar.gz && sha256sum prometheus-2.49.1.linux-arm64.tar.gz
mkdir -p /opt/prometheus/{bin,conf,data}
然后解压到 bin 目录,并且把顶层文件夹剥掉:
tar -zxvf prometheus-2.49.1.linux-arm64.tar.gz -C /opt/prometheus/bin --strip-components=1
接下来,把默认的配置模板搬到 conf 目录里:
cp /opt/prometheus/bin/prometheus.yml /opt/prometheus/conf/
最后,给主程序加上可执行权限:
chmod +x /opt/prometheus/bin/prometheus
vim /opt/prometheus/conf/prometheus.yml
在 scrape_configs: 下面,插入一个静态任务(注意缩进必须是2个空格):
- job_name: 'prometheus'同时,记得在
static_configs:
- targets: ['localhost:9090']
global: 块里把采集间隔设置好。在ARM平台上,建议不小于30s,太短的话,低性能设备可能会扛不住:
scrape_interval: 30s
保存后,用 promtool 检查一下语法,这个检查直接决定后面能不能跑起来:
/opt/prometheus/bin/promtool check config /opt/prometheus/conf/prometheus.yml
输出 “SUCCESS” 才说明没问题。
useradd -r -s /sbin/nologin prometheus
第二步,把整个部署目录的归属权交给这个用户:
chown -R prometheus:prometheus /opt/prometheus
第三步,切换到这个用户,在前台跑一下 Prometheus,看看日志有没有异常:
sudo -u prometheus /opt/prometheus/bin/prometheus第四步,另开一个终端,检查 9090 端口是不是在监听了:
--config.file=/opt/prometheus/conf/prometheus.yml
--storage.tsdb.path=/opt/prometheus/data
--web.console.libraries=/opt/prometheus/bin/console_libraries
--web.console.templates=/opt/prometheus/bin/consoles
ss -tlnp | grep :9090
看到 prometheus 的进程在,就说明启动成功了。
第五步,打开浏览器,访问 http://本机IP:9090/targets,确认状态那一栏是 UP,标签显示 instance="localhost:9090"。
sudo vim /etc/systemd/system/prometheus.service
填入下面内容,注意 User 和 ExecStart 的路径一定要和实际部署的一致:
[Unit]重载 systemd 配置,然后启用并立即启动服务:
Description=Prometheus Monitoring System
After=network.target
[Service]
Type=simple
User=prometheus
Group=prometheus
ExecStart=/opt/prometheus/bin/prometheus
--config.file=/opt/prometheus/conf/prometheus.yml
--storage.tsdb.path=/opt/prometheus/data
--web.console.libraries=/opt/prometheus/bin/console_libraries
--web.console.templates=/opt/prometheus/bin/consoles
--web.enable-lifecycle
Restart=always
RestartSec=10
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload && sudo systemctl enable --now prometheus
最后,检查一下服务状态:
sudo systemctl status prometheus
输出中包含 “active (running)”,整个部署就算完成了。
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
正版软件
正版软件
正版软件
正版软件
正版软件
1
2
3
4
5
6
7
8
9