如何在 Manjaro 上安装 Prometheus R00T型

Linux命令 Edge插件网 1年前 (2023-11-10) 267次浏览 已收录 0个评论

Prometheus 是一个功能丰富的监控系统,具有广泛的优势,例如实时数据收集、警报功能和用户友好的基于 Web 的仪表板。

如何在 Manjaro 上安装 Prometheus R00T型

在 Manjaro 上安装 Prometheus

步骤 1。在深入研究 Prometheus 安装之前,确保您的 Manjaro 系统是最新的至关重要。打开终端并执行以下命令:

<span class="pln">sudo pacman </span><span class="pun">-</span><span class="typ">Syu</span><span class="pln">
sudo pacman </span><span class="pun">-</span><span class="pln">S git </span><span class="kwd">base</span><span class="pun">-</span><span class="pln">devel</span>

第2步。在 Manjaro 上安装 Prometheus。

要安装 Prometheus,我们将下载 Prometheus 二进制文件,为 Prometheus 创建专用用户和组,设置配置,并将 Prometheus 作为服务运行。systemd

  • 方法 1:手动下载和安装二进制文件。

现在访问 Prometheus 下载页面并获取最新版本的 URL。在撰写本文时,最新版本为 2.47.2,但您应该使用可用的最新版本。

<span class="pln">wget https</span><span class="pun">:</span><span class="com">//github.com/prometheus/prometheus/releases/download/v2.47.2/prometheus-2.47.2.linux-amd64.tar.gz</span>

运行以下命令,将 prometheus 二进制文件移动到 /usr/local/bin

<span class="pln">sudo mv prometheus</span><span class="pun">-</span><span class="lit">2.47</span><span class="pun">.</span><span class="lit">2.linux</span><span class="pun">-</span><span class="pln">amd64</span><span class="pun">/</span><span class="pln">prometheus </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span>

通过运行以下命令为 Prometheus 创建新用户:

<span class="pln">sudo useradd </span><span class="pun">--</span><span class="kwd">no</span><span class="pun">-</span><span class="pln">create</span><span class="pun">-</span><span class="pln">home </span><span class="pun">--</span><span class="pln">shell </span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="kwd">false</span><span class="pln"> prometheus</span>

通过运行以下命令为 Prometheus 数据创建一个新目录:

<span class="pln">sudo mkdir </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">lib</span><span class="pun">/</span><span class="pln">prometheus</span>

通过运行以下命令,将 /var/lib/prometheus 目录的所有权更改为 prometheus 用户:

<span class="pln">sudo chown prometheus</span><span class="pun">:</span><span class="pln">prometheus </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">lib</span><span class="pun">/</span><span class="pln">prometheus</span>

通过运行以下命令为 Prometheus 配置文件创建一个新目录:

<span class="pln">sudo mkdir </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">prometheus</span>

移动普罗米修斯YML公司配置文件复制到 /etc/prometheus 目录下,执行以下命令:

<span class="pln">sudo mv prometheus</span><span class="pun">-</span><span class="lit">2.47</span><span class="pun">.</span><span class="lit">2.linux</span><span class="pun">-</span><span class="pln">amd64</span><span class="pun">/</span><span class="pln">prometheus</span><span class="pun">.</span><span class="pln">yml </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">prometheus</span><span class="pun">/</span>

通过运行以下命令,将 /etc/prometheus 目录的所有权更改为 prometheus 用户:

<span class="pln">sudo chown prometheus</span><span class="pun">:</span><span class="pln">prometheus </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">prometheus</span>

通过运行以下命令为 Prometheus 创建新的 systemd 服务文件:

<span class="pln">sudo nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">systemd</span><span class="pun">/</span><span class="pln">system</span><span class="pun">/</span><span class="pln">prometheus</span><span class="pun">.</span><span class="pln">service</span>

将以下内容粘贴到文件中:

<span class="pun">[</span><span class="typ">Unit</span><span class="pun">]</span>
<span class="typ">Description</span><span class="pun">=</span><span class="typ">Prometheus</span>
<span class="typ">Wants</span><span class="pun">=</span><span class="pln">network</span><span class="pun">-</span><span class="pln">online</span><span class="pun">.</span><span class="pln">target
</span><span class="typ">After</span><span class="pun">=</span><span class="pln">network</span><span class="pun">-</span><span class="pln">online</span><span class="pun">.</span><span class="pln">target

</span><span class="pun">[</span><span class="typ">Service</span><span class="pun">]</span>
<span class="typ">User</span><span class="pun">=</span><span class="pln">prometheus
</span><span class="typ">Group</span><span class="pun">=</span><span class="pln">prometheus
</span><span class="typ">Type</span><span class="pun">=</span><span class="pln">simple
</span><span class="typ">ExecStart</span><span class="pun">=</span><span class="str">/usr/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">prometheus \
    </span><span class="pun">--</span><span class="pln">config</span><span class="pun">.</span><span class="pln">file </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">prometheus</span><span class="pun">/</span><span class="pln">prometheus</span><span class="pun">.</span><span class="pln">yml \
    </span><span class="pun">--</span><span class="pln">storage</span><span class="pun">.</span><span class="pln">tsdb</span><span class="pun">.</span><span class="pln">path </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">lib</span><span class="pun">/</span><span class="pln">prometheus \
    </span><span class="pun">--</span><span class="pln">web</span><span class="pun">.</span><span class="pln">console</span><span class="pun">.</span><span class="pln">templates</span><span class="pun">=</span><span class="str">/usr/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">consoles \
    </span><span class="pun">--</span><span class="pln">web</span><span class="pun">.</span><span class="pln">console</span><span class="pun">.</span><span class="pln">libraries</span><span class="pun">=</span><span class="str">/usr/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">console_libraries
</span><span class="typ">Restart</span><span class="pun">=</span><span class="pln">always

</span><span class="pun">[</span><span class="typ">Install</span><span class="pun">]</span>
<span class="typ">WantedBy</span><span class="pun">=</span><span class="pln">multi</span><span class="pun">-</span><span class="pln">user</span><span class="pun">.</span><span class="pln">target</span>

保存并关闭文件,然后通过运行以下命令来关闭 Prometheus 服务:

<span class="pln">sudo systemctl daemon</span><span class="pun">-</span><span class="pln">reload
sudo systemctl start prometheus</span>
  • 方法 2:使用包管理器。

通过运行以下命令安装 Prometheus:

<span class="pln">sudo pacman </span><span class="pun">-</span><span class="pln">S prometheus</span>

通过运行以下命令验证 Prometheus 是否已安装:

<span class="pln">prometheus </span><span class="pun">--</span><span class="pln">version</span>

安装 Prometheus 后,启动 Prometheus 服务并使其在系统重启时启动:

<span class="pln">sudo systemctl start prometheus 
sudo systemctl start prometheus</span>

第 3 步。防火墙配置。

如果启用了防火墙,请确保允许端口 9090(Prometheus 的默认端口)上的传入流量:

<span class="pln">sudo ufw allow </span><span class="lit">9090</span><span class="pun">/</span><span class="pln">tcp</span>

第 4 步。访问 Prometheus Web UI。

现在,您可以从本地网络上的 Web 浏览器访问 Prometheus Web UI,方法是输入服务器的 IP 地址,然后输入端口 9090:

<span class="pln">http</span><span class="pun">:</span><span class="com">//your_server_ip:9090</span>

如何在 Manjaro 上安装 Prometheus R00T型

感谢您使用本教程在 Manjaro 系统上安装最新版本的 Prometheus 监控系统。如需更多帮助或有用信息,我们建议您查看 Prometheus 官方网站

 

VPS管理服务报价

Edge插件网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何在 Manjaro 上安装 Prometheus R00T型
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址