如何在 Debian 12 上安装 Cacti

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

Cacti 是一款基于 Web 的网络监控和绘图工具,旨在利用简单网络管理协议 (SNMP) 的强大功能,创建网络性能数据的富有洞察力的图形表示。使用 Cacti,您可以可视化和分析网络流量、服务器性能以及对于维护稳定高效的 IT 基础架构至关重要的各种其他指标。

如何在 Debian 12 上安装 Cacti

在 Debian 12 书虫上安装 Cacti

第 1 步。在我们安装任何软件之前,通过在终端中运行以下命令来确保您的系统是最新的非常重要:apt

<span class="pln">sudo apt update
sudo apt upgrade</span>

此命令更新软件包列表并将已安装的软件包升级到最新版本。

第 2 步。安装必要的依赖项。

让我们从安装 Cacti 所需的基本软件包开始:

<span class="pln">sudo apt install apache2 mariadb</span><span class="pun">-</span><span class="pln">server php php</span><span class="pun">-</span><span class="pln">mysql php</span><span class="pun">-</span><span class="pln">snmp php</span><span class="pun">-</span><span class="pln">gd php</span><span class="pun">-</span><span class="pln">ldap php</span><span class="pun">-</span><span class="pln">net</span><span class="pun">-</span><span class="pln">socket php</span><span class="pun">-</span><span class="pln">xml php</span><span class="pun">-</span><span class="pln">zip php</span><span class="pun">-</span><span class="pln">mbstring snmp snmpd rrdtool</span>

第 3 步。在 Debian 12安装 Cacti

访问 Cacti 网站下载最新版本:

<span class="pln">wget https</span><span class="pun">:</span><span class="com">//files.cacti.net/cacti/linux/cacti-latest.tar.gz</span>

提取下载的仙人掌存档:

<span class="pln">tar </span><span class="pun">-</span><span class="pln">xzvf cacti</span><span class="pun">-</span><span class="pln">latest</span><span class="pun">.</span><span class="pln">tar</span><span class="pun">.</span><span class="pln">gz</span>

将解压缩的 Cacti 文件移动到 Web 服务器的文档根目录:

<span class="pln">sudo mv cacti</span><span class="pun">-*</span><span class="str">/ /</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">cacti</span>

第 4 步。为 Cacti 配置 MySQL 数据库。

以根用户身份登录 MySQL 服务器:

<span class="pln">sudo mysql </span><span class="pun">-</span><span class="pln">u root </span><span class="pun">-</span><span class="pln">p</span>

执行以下 SQL 命令以创建数据库、用户并为 Cacti 授予权限:

<span class="pln">CREATE DATABASE cacti</span><span class="pun">;</span><span class="pln">
GRANT ALL PRIVILEGES ON cacti</span><span class="pun">.*</span><span class="pln"> TO </span><span class="str">'cactiuser'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pln"> IDENTIFIED BY </span><span class="str">'your_strong_password'</span><span class="pun">;</span><span class="pln">
FLUSH PRIVILEGES</span><span class="pun">;</span>
<span class="kwd">exit</span><span class="pun">;</span>

为确保正确收集数据,请导入 Cacti 的默认数据模板:

<span class="pln">mysql </span><span class="pun">-</span><span class="pln">u cactiuser </span><span class="pun">-</span><span class="pln">p cacti </span><span class="pun"><</span> <span class="str">/var/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">cacti</span><span class="pun">/</span><span class="pln">cacti</span><span class="pun">.</span><span class="pln">sql</span>

配置仙人掌数据库设置:

<span class="pln">sudo nano </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">cacti</span><span class="pun">/</span><span class="pln">include</span><span class="pun">/</span><span class="pln">config</span><span class="pun">.</span><span class="pln">php</span>

修改以下行以匹配您的设置:

<span class="pln">$database_type </span><span class="pun">=</span> <span class="str">"mysql"</span><span class="pun">;</span><span class="pln">
$database_default </span><span class="pun">=</span> <span class="str">"cacti"</span><span class="pun">;</span><span class="pln">
$database_hostname </span><span class="pun">=</span> <span class="str">"localhost"</span><span class="pun">;</span><span class="pln">
$database_username </span><span class="pun">=</span> <span class="str">"cactiuser"</span><span class="pun">;</span><span class="pln">
$database_password </span><span class="pun">=</span> <span class="str">"your_strong_password"</span><span class="pun">;</span>

第5步。将 Web 服务器配置为为仙人掌提供服务

为 Cacti 创建一个虚拟主机配置文件:

<span class="pln">sudo nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">apache2</span><span class="pun">/</span><span class="pln">sites</span><span class="pun">-</span><span class="pln">available</span><span class="pun">/</span><span class="pln">cacti</span><span class="pun">.</span><span class="pln">conf</span>

添加以下内容,并根据需要调整值:

<span class="tag"><VirtualHost</span><span class="pln"> *:80</span><span class="tag">></span><span class="pln">
ServerAdmin webmaster@example.com
DocumentRoot /var/www/html/cacti

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</span><span class="tag"><Directory</span> <span class="pun">/</span><span class="atn">var</span><span class="pun">/</span><span class="atn">www</span><span class="pun">/</span><span class="atn">html</span><span class="pun">/</span><span class="atn">cacti</span><span class="tag">/></span><span class="pln">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</span><span class="tag"></Directory></span>
<span class="tag"></VirtualHost></span>

启用虚拟主机和 Apache 模块:

<span class="pln">sudo a2ensite cacti</span><span class="pun">.</span><span class="pln">conf
sudo a2enmod rewrite
sudo systemctl restart apache2</span>

第 6 步。设置 cron 作业。

通过编辑 crontab 来创建轮询器 cron 作业:

<span class="pln">sudo crontab </span><span class="pun">-</span><span class="pln">e</span>

添加以下行:

<span class="pun">*</span><span class="str">/5 * * * * /</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">php </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">cacti</span><span class="pun">/</span><span class="pln">poller</span><span class="pun">.</span><span class="pln">php </span><span class="pun">--</span><span class="pln">force</span>

This schedules the poller to run every 5 minutes.

这会将轮询器安排为每 5 分钟运行一次。

步骤 7.访问仙人掌网页界面。

打开 Web 浏览器并导航到 http//localhost/cacti。您应该会看到仙人掌登录页面。使用默认凭据:

  • 用户名:管理员
  • 密码:管理员

如何在 Debian 12 上安装 Cacti

登录后,系统将提示您更改默认密码。按照说明设置安全密码。接下来,配置您的 Cacti 用户帐户、电子邮件设置和时区首选项。

感谢您使用本教程在 Debian 12 书虫上安装最新版本的 Cacti 监控。如需其他帮助或有用信息,我们建议您查看仙人掌官方网站


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

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

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