【Promethues】Linux下指定配置启动prometheus命令

本文介绍Prometheus监控系统的启动命令,并强调如何使用正确的方法将其置于后台运行以避免因Ctrl+C操作导致的服务中断。

Promethues启动命令:

./prometheus --config.file=/home/clickhouse/prometheus/prometheus.yml

这种方式启动ctrl+C就宕了,要保持后台启动,后面加一个&

./prometheus --config.file=/home/clickhouse/prometheus/prometheus.yml&
### 安装 Prometheus 3.0 on Rocky Linux #### 准备工作 为了确保顺利安装Prometheus 3.0,在Rocky Linux环境中需先更新系统软件包并安装必要的工具。 ```bash sudo yum update -y sudo yum install wget -y ``` #### 下载 Prometheus 访问Prometheus官方网站获取最新版下载链接,对于特定版本如3.0, 需要确认该版本的具体发布页面来获得确切的文件名。假设当前最新的稳定版本对应于`prometheus-3.0.linux-amd64.tar.gz`这样的命名模式,则执行如下操作: ```bash cd /tmp/ wget https://assets.prometheus.io/releases/prometheus-3.0.linux-amd64.tar.gz ``` #### 移动解压后的文件到指定位置 创建一个专门用于存放Prometheus二进制及相关配置文件的位置,并设置合适的权限以便后续管理和服务运行[^1]。 ```bash mkdir -p /opt/prometheus mv prometheus-3.0.linux-amd64/* /opt/prometheus/ rm -rf prometheus-3.0.linux-amd64 prometheus-3.0.linux-amd64.tar.gz chown -R nobody:nobody /opt/prometheus ``` #### 创建服务单元文件 为了让Prometheus能够作为守护进程启动,需要编写Systemd的服务定义文件 `/etc/systemd/system/prometheus.service`. ```ini [Unit] Description=Prometheus Monitoring System and Time Series Database After=network.target [Service] User=nobody Group=nobody Type=simple ExecStart=/opt/prometheus/prometheus \ --config.file=/opt/prometheus/prometheus.yml \ --storage.tsdb.path=/opt/prometheus/data \ --web.console.templates=/opt/prometheus/consoles \ --web.console.libraries=/opt/prometheus/console_libraries Restart=on-failure [Install] WantedBy=multi-user.target ``` #### 启动与启用Prometheus服务 完成上述步骤之后,即可通过systemctl命令控制Prometheus服务的状态。 ```bash systemctl daemon-reload systemctl start prometheus systemctl enable prometheus ``` 此时应该可以通过浏览器访问默认监听地址 `http://<your_server_ip>:9090` 来验证Prometheus是否正常运作。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值