一,Prometheus安装
1,官网下载
https://prometheus.io/download/
2, 解压二进制包
tar -xf prometheus-2.23.0.linux-amd64.tar.gz
mv prometheus-2.23.0.linux-amd64 /usr/local/prometheus
3, 创建用户
groupadd prometheus
useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
chown prometheus.prometheus -R /usr/local/prometheus
4,使用systemd管理服务
cat > /etc/systemd/system/prometheus.service <<EOF
[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=/var/lib/prometheus/data
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
5,启动prometheus
systemctl start prometheus.service
systemctl enable prometheus.service
查看状态:
[root@prometheus ~]# ps -ef |grep prometheus
prometh+ 17902 1 0 09:16 ? 00:00:00 /usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus/data
root 17952 17749 0 09:18 pts/0 00:00:00 grep --color=auto prometheus
[root@prometheus ~]# ss -lntup |grep 9090
tcp LISTEN 0 128 :::9090 :::* users:(("prometheus",pid=17902,fd=9))
6, web页面
如果web页面打不开请关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service