安装
wget https://github.com/prometheus/prometheus/releases/download/v2.8.1/prometheus-2.8.1.linux-amd64.tar.gz
tar -zxvf prometheus-2.8.1.linux-amd64.tar.gz -C /usr/local/ cd /usr/local mv prometheus-2.8.1.linux-amd64/ prometheus cd prometheus/ ./prometheus --version
修改prometheus.yml文件,确定启动ip

完成修改后,可以直接启动
./prometheus
# 添加用户,后期用此账号启动服务
[root@localhost prometheus]# groupadd prometheus
[root@localhost prometheus]# useradd -g prometheus -s /sbin/nologin prometheus
# 赋权和创建prometheus运行数据目录
[root@localhost prometheus]# cd ~
[root@localhost ~]# chown -R prometheus:prometheus /usr/local/prometheus/
[root@localhost ~]# mkdir -p /home/software/prometheus-data
[root@localhost ~]# chown -R prometheus:prometheus /home/software/prometheus-data
设置开机启动
[root@localhost ~]# touch /usr/lib/systemd/system/prometheus.service
[root@localhost ~]# chown prometheus:prometheus /usr/lib/systemd/system/prometheus.service
[root@localhost ~]# vim /usr/lib/systemd/system/prometheus.service
[Unit] Description=Prometheus Documentation=https://prometheus.io/ After=network.target [Service] # Type设置为notify时,服务会不断重启 Type=simple User=prometheus # --storage.tsdb.path是可选项,默认数据目录在运行目录的./dada目录中 ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/home/software/prometheus-data Restart=on-failure [Install] WantedBy=multi-user.target
[root@prometheus ~]# systemctl enable prometheus
[root@prometheus ~]# systemctl start prometheus
[root@prometheus ~]# systemctl status prometheus

prometheus 热加载
如果是system 管理 在prometheus.service 配置中加 --web.enable-lifecycle

docker启动同理后续加 --web.enable-lifecycle curl -X POST http://ip:9090/-/reload
浙公网安备 33010602011771号