**下载地址:**https://github.com/prometheus/prometheus/releases
因为服务器上下载速度太慢,所以可以提前在物理机上下载上传到服务器,本次安装使用的版本为:prometheus-2.37.5.linux-amd64
cd /prometheus
#解压
tar -xvzf prometheus-2.37.5.linux-amd64.tar.gz
mv prometheus-2.37.5.linux-amd64 prometheus
cd prometheus
cp prom* /usr/bin/
prometheus --version
–config.file="/data/prometheus/prometheus.yml" //指定配置文件路径
–web.enable-lifecycle //开启web热加载配置
–storage.tsdb.path= //指定tsdb数据库路径,默认在/data
–storage.tsdb.retention.time= //指定tsdb保留数据的时长,默认15d
prometheus --config.file="/prometheus/prometheus/prometheus.yml" --web.enable-lifecycle
prometheus.service
配置文件cd /usr/lib/systemd/system
vim prometheus.service
:wq
[Unit]
Description=https://prometheus.io
[Service]
Restart=on-failure
ExecStart=/prometheus/prometheus/prometheus --config.file=/prometheus/prometheus/prometheus.yml --web.enable-lifecycle --storage.tsdb.path=/prometheus/prometheus/data
[Install]
WantedBy=multi-user.target
chmod -R 777 /prometheus/
chown -R root /prometheus/
journalctl -u prometheus.service
systemctl daemon-reload
systemctl start prometheus.service
systemctl status prometheus.service
ps -ef | grep prometheus
systemctl enable prometheus.service
vim /prometheus/prometheus/prometheus.yml
curl -XPOST [your ip]:9090/-/reload
稍等片刻刷新系统,就可以看到ip地址已经变更成功
点击Endpoint地址,查看数据返回