环境:
os:Centos
1.二进制包下载地址
https://prometheus.io/download/
cd /soft
wget https://github.com/prometheus/prometheus/releases/download/v3.1.0/prometheus-3.1.0.linux-amd64.tar.gz
2.安装
[root@prometheus local]#tar zxvf prometheus-3.1.0.linux-amd64.tar.gz
[root@prometheus local]#mv prometheus-3.1.0.linux-amd64 /opt/prometheus
[root@prometheus local]#cd /opt/prometheus
[root@prometheus prometheus]#mkdir bin conf data
[root@prometheus prometheus]#mv prometheus promtool bin/
[root@prometheus prometheus]#mv prometheus.yml conf/
3.检查配置文件是否正确
[root@localhost prometheus]# /opt/prometheus/bin/promtool check config /opt/prometheus/conf/prometheus.yml
Checking /opt/prometheus/conf/prometheus.ymlSUCCESS: /opt/prometheus/conf/prometheus.yml is valid prometheus config file syntax
4.创建 service 文件配置开机启动
[root@prometheus ~]#vi /lib/systemd/system/prometheus.service
[root@prometheus ~]#cat /lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network.target
[Service]
Restart=on-failure
User=root
Group=root
WorkingDirectory=/opt/prometheus/
ExecStart=/opt/prometheus/bin/prometheus --config.file=/opt/prometheus/conf/prometheus.yml
ExecReload=/bin/kill -HUP $MAINPID
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
[root@prometheus ~]#systemctl daemon-reload
[root@prometheus ~]#systemctl enable --now prometheus.service
[root@prometheus ~]#ss -tnlp |grep prometheus
LISTEN 0 128 *:9090 *:*
users:(("prometheus",pid=84755,fd=10))
#结果显示:可以看到当前主机上可以看到一个端口9090,可通过本机ip+9090看到prometheus的服务页面
5.查看服务状态
systemctl status prometheus.service