要在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監控工具。