在CentOS上安装Cacti并进行网络配置,可以按照以下步骤进行:
首先,确保系统是最新的,并安装必要的软件包:
sudo yum update -y
sudo yum install -y epel-release
sudo yum install -y mariadb-server mariadb
sudo yum install -y php php-mysqlnd php-gd php-mbstring php-xml php-zip
sudo yum install -y snmpd snmp-utils
sudo yum install -y webtatic-release
sudo yum install -y cacti
启动并启用MariaDB服务:
sudo systemctl start mariadb
sudo systemctl enable mariadb
运行安全安装脚本来设置root密码和其他安全选项:
sudo mysql_secure_installation
创建一个用于Cacti的数据库和用户:
sudo mysql -u root -p
在MySQL提示符下执行以下命令:
CREATE DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'cacti'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON cacti.* TO 'cacti'@'localhost';
FLUSH PRIVILEGES;
EXIT;
将Cacti的Web配置文件复制到Web服务器的目录中(例如,Apache的/var/www/html/
):
sudo cp -R /usr/share/doc/cacti-1.2.4/html/* /var/www/html/
编辑Cacti的配置文件/etc/cacti/config.php
,找到数据库连接部分并进行修改:
$database['default']['driver'] = 'mysql';
$database['default']['hostname'] = 'localhost';
$database['default']['username'] = 'cacti';
$database['default']['password'] = 'your_password';
$database['default']['database'] = 'cacti';
$database['default']['prefix'] = '';
确保SNMP服务正在运行:
sudo systemctl start snmpd
sudo systemctl enable snmpd
编辑SNMP配置文件/etc/snmp/snmpd.conf
,确保以下行未被注释:
com2sec = public community
sysuptime.0 = 1
重启SNMP服务:
sudo systemctl restart snmpd
确保Apache已启用并正在运行:
sudo systemctl start httpd
sudo systemctl enable httpd
编辑Apache虚拟主机配置文件(例如/etc/httpd/conf.d/cacti.conf
),添加以下内容:
<VirtualHost *:80>
ServerName your_domain_or_ip
DocumentRoot /var/www/html/cacti
<Directory /var/www/html/cacti>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/cacti-error.log
CustomLog /var/log/httpd/cacti-access.log combined
</VirtualHost>
重启Apache服务:
sudo systemctl restart httpd
现在,你应该能够通过浏览器访问Cacti的Web界面(例如http://your_domain_or_ip/cacti/
)。登录后,你可以开始配置Cacti并添加设备以监控网络流量。