1. 解压prometheus压缩包:
[root@node5 ~]# tar xf prometheus-2.38.0.linux-amd64.tar.gz -C /usr/local/
2. 对压缩后的文件做软连接:
[root@node5 ~]# ln -sv /usr/local/prometheus-2.38.0.linux-amd64/ /usr/local/prometheus
3. 创建用户:
[root@snode5 ~]# useradd prometheus -M -s /sbin/nologin
4. 创建prometheus监控数据存放的目录:
[root@node5 ~]# mkdir /usr/local/prometheus/data
5. 修改目录的属主:
[root@node5 ~]# chown -R prometheus /usr/local/prometheus/*
6. 配置服务启动脚本:
- [root@node5 ~]# vim /usr/lib/systemd/system/prometheus.service
-
- [Unit]
- Description=prometheus
- After=network.target
-
- [Service]
- Type=simple
- User=prometheus
- ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/usr/local/prometheus/data
- Restart=on-failure
- ExecReload=/bin/kill -HUP SMAINPID
-
- [Install]
- WantedBy=multi-user.target
7. 启动服务:
- [root@slave2 ~]# systemctl daemon-reload
-
- [root@slave2 ~]# systemctl enable --now prometheus.service
-
- [root@slave2 ~]# systemctl is-active prometheus.service
- active
-
- ##prometheus服务默认端口是9090,查看端口是否监听
- [root@slave2 ~]# ss -lntup | grep 9090
- tcp LISTEN 0 4096 [::]:9090 [::]:* users:(("prometheus",pid=22161,fd=7))
8. 访问prometheus的web页面:
http://192.168.188.115:9090/