debian 10 安装prometheus 2.37.6 配置rc.local自启动
debian 10 安装prometheus 2.37.6 配置rc.local自启动
1、下载安装包
https://prometheus.io/download/
wget -c https://github.com/prometheus/prometheus/releases/download/v2.37.6/prometheus-2.37.6.linux-amd64.tar.gz
2、安装
解压安装包至 /usr/local/目录
tar -zxvf prometheus-2.37.6.linux-amd64.tar.gz -C /usr/local/
修改安装目录名称为prometeus
cd /usr/local/ mv prometheus-2.37.6.linux-amd64/ prometheus
启动prometeus服务
cd prometheus
nohup ./prometheus --storage.tsdb.path="data/" --storage.tsdb.retention=30d --config.file=prometheus.yml > ./prometheus.log 2>&1 &
参数释义
--storage.tsdb.path="data/" Base path for metrics storage. Use with server mode only. --storage.tsdb.retention=STORAGE.TSDB.RETENTION [DEPRECATED] How long to retain samples in storage. This flag has been deprecated, use "storage.tsdb.retention.time" instead. Use with server mode only. --config.file="prometheus.yml" Prometheus configuration file path.
自动生成data目录和prometheus.log文件
3、访问普罗米修斯
4、加入开机自启动
4.1、配置rc-local.service
debian 10 中在 /etc/rc.local 添加自定义的命令即可实现开机自动执行命令:开机自启动。
debian 10 默认安装了rc-local 服务,但是没有启动,所以默认也没有 /etc/rc.local 文件。
默认 rc-local 服务没有启动
systemctl status rc-local 显示Active: inactive (dead)就是没有启动。
默认的rc-local.service文件
启动rc-local 服务
启动失败 因为condition验证失败,就是说系统上没有/etc/rc.local文件。
那么先建立 /etc/rc.local 文件,并赋予可执行权限
touch /etc/rc.local chmod +x /etc/rc.local
再次启动rc-local服务 报错
systemctl start rc-local.service
/etc/rc.local格式错误
编辑/etc/rc.local文件,加入一行:#!/bin/bash
vi /etc/rc.local
再次启动rc-local服务
systemctl start rc-local.service
4.2、添加自定义启动命令
编辑/etc/rc.local文件
vi /etc/rc.local
加入一行:
nohup /usr/local/prometheus/prometheus --storage.tsdb.path="/usr/local/prometheus/data/" --storage.tsdb.retention=30d --config.file=/usr/local/prometheus/prometheus.yml > /usr/local/prometheus/prometheus.log 2>&1 &
重启服务器看普罗米修斯是否在运行
4.3、查看rc-local.service
systemctl status rc-local.service
可以看到CGroup里显示出所有通过/etc/rc.local配置的自启动服务
本文来自博客园,作者:OceanWaves,转载请注明原文链接:https://www.cnblogs.com/OceanWaves/p/17312419.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)