Prometheus下载安装

cd /opt

mkdir prometheus

cd prometheus 
//下载
wget https://github.com/prometheus/prometheus/releases/download/v2.45.1/prometheus-2.45.1.linux-amd64.tar.gz

//解压
tar -zxvf prometheus-2.45.1.linux-amd64.tar.gz

//创建数据存放目录
mkdir prometheus/data

//rometheus官方只提供了二进制文件tar包,为了方便管理,我们可以创建prometheus系统服务启动文件

vim /etc/systemd/system/prometheus.service
输入:
[Unit]
Description=Prometheus service
After=network.target

[Service]
User=root
Type=simple
ExecReload=/bin/sh -c "/bin/kill -1 `/usr/bin/pgrep prometheus`"
ExecStop=/bin/sh -c "/bin/kill -9 `/usr/bin/pgrep prometheus`"
ExecStart=/opt/prometheus/prometheus --config.file=/opt/prometheus/prometheus.yml --storage.tsdb.path=/opt/prometheus/data --storage.tsdb.retention.time=30d --storage.tsdb.retention.size=30GB

[Install]
WantedBy=multi-user.target

  • 说明:当使用其他目录部署时,注意ExecStart命令中的目录需要同步修改一致。此外,在启动参数中我们还配置了Prometheus中数据存储的过期条件为“30天”或“大于30GB”,可以按需修改
//启动服务:
systemctl daemon-reload
systemctl start prometheus.service

//prometheus默认使用的端口为9090,也可以使用netstat命令查看9090端口的状态
netstat -nltp | grep 9090
//设置开机启动
systemctl enable prometheus.service

其他相关命令:

  • 停止服务:systemctl stop prometheus.service

  • 重启服务:systemctl restart prometheus.service

  • 热加载配置:systemctl reload prometheus.service

  • 禁用开机启动:systemctl disable prometheus.service

登录

  • http://IP:9090/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值