要在CentOS上安装和配置Cacti监控工具,可以按照以下步骤操作:
sudo yum install httpd php php-mysql php-snmp php-xml php-xmlrpc php-gd php-mbstring mariadb-server net-snmp net-snmp-utils
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation
mysql -u root -p
CREATE DATABASE cacti;
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit;
mysql -u cactiuser -p cacti < /usr/share/doc/cacti/cacti.sql
sudo vi /etc/cacti/db.php
将以下内容粘贴到文件中并保存:
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "password";
$database_port = "3306";
$database_ssl = false;
sudo vi /etc/httpd/conf.d/cacti.conf
将以下内容粘贴到文件中并保存:
Alias /cacti /usr/share/cacti
<Directory /usr/share/cacti/>
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
Allow from all
</IfModule>
</Directory>
sudo vi /etc/snmp/snmpd.conf
找到以下两行并取消注释:
view systemview included .1
rocommunity public localhost
重启snmpd服务:
sudo systemctl restart snmpd
sudo vi /etc/cron.d/cacti
将以下内容粘贴到文件中并保存:
*/5 * * * * apache php /usr/share/cacti/poller.php > /dev/null 2>&1
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl start snmpd
sudo systemctl enable snmpd
通过以上步骤,您可以在CentOS上成功安装和配置Cacti监控工具。