下载Prometheus二进制文件
sh
wget https://github.com/prometheus/prometheus/releases/download/v2.47.2/prometheus-2.47.2.linux-amd64.tar.gz
解压缩,查看文件内容
sh
tar -xf prometheus-2.47.2.linux-amd64.tar.gz -C /usr/local/
sh
root@node1:~/prometheus-2.47.2.linux-amd64# tree
.
├── console_libraries
│ ├── menu.lib
│ └── prom.lib
├── consoles
│ ├── index.html.example
│ ├── node-cpu.html
│ ├── node-disk.html
│ ├── node.html
│ ├── node-overview.html
│ ├── prometheus.html
│ └── prometheus-overview.html
├── LICENSE
├── NOTICE
├── prometheus # prometheus二进制程序文件
├── prometheus.yml
└── promtool # prometheus配置文件检查工具
创建软链接
sh
root@node1:~# ln -s /usr/local/prometheus-2.47.2.linux-amd64/ /usr/local/prometheus
创建Service文件
sh
root@node1:/usr/local/prometheus# cat /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
After=network.target
[Service]
WorkingDirectory=/usr/local/prometheus
ExecStart=/usr/local/prometheus/prometheus --config.file="/usr/local/prometheus/prometheus.yml"
[install]
WantedBy=multi-user.target
启动服务
sh
systemctl daemon-reload
systemctl start prometheus.service
访问服务
默认端口9090