LAMP环境的安装可参考: CentOS8_lnmp1.7_LAMP_安装Nagios
[root@redhat8 ~]# /usr/local/apache/bin/httpd -v
Server version: Apache/2.4.46 (Unix)
Server built: Aug 14 2021 14:58:50
[root@redhat8 ~]# mysql -V
mysql Ver 14.14 Distrib 5.1.73, for unknown-linux-gnu (x86_64) using readline 5.1
[root@redhat8 ~]# php -v
PHP 5.3.29 (cli) (built: Aug 14 2021 15:05:35)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies
安装snmp、rrdtool:(使用本地光盘作为Yum源即可)
[root@redhat8 ~]# dnf -y install php-snmp net-snmp-utils rrdtool
安装Cacti:
tar -zxvf cacti-0.8.8b.tar.gz -C /usr/local/
mkdir /home/wwwroot/default/cacti
mv /usr/local/cacti-0.8.8b/* /home/wwwroot/default/cacti
rm -rf /usr/local/cacti-0.8.8b/
chown -R www:www /home/wwwroot/default/cacti
给Cacti创建库:
[root@redhat8 ~]# mysql -uroot -p888
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73-log Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database cacti CHARACTER SET latin1;
Query OK, 1 row affected (0.00 sec)
mysql> show create database cacti;
+----------+------------------------------------------------------------------+
| Database | Create Database |
+----------+------------------------------------------------------------------+
| cacti | CREATE DATABASE `cacti` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+----------+------------------------------------------------------------------+
1 row in set (0.00 sec)
查看所有数据库用户及其主机信息:
mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
+------+-----------+
2 rows in set (0.00 sec)
查看数据库管理员root@localhost的权限:
mysql> show grants for root@localhost;
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*41DDB5DFD213B288EE050BD64DC6AA36815A3486' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
将目录/home/wwwroot/default/cacti/里的cacti.sql 导入到MySQL的库cacti里:
[root@redhat8 ~]# mysql -uroot -p888 cacti < /home/wwwroot/default/cacti/cacti.sql
修改Cacti的配置文件里的数据库连接信息:
[root@redhat8 ~]# vi /home/wwwroot/default/cacti/include/config.php
######
添加Monitor,Thold等插件:
cd /root/cacti-plugin/
tar -zxvf cacti-plugin-0.8.7g-PA-v2.8.tar.gz -C /tmp/
cd /home/wwwroot/default/cacti/
patch -p1 -N < /tmp/cacti-plugin-arch/cacti-plugin-0.8.7g-PA-v2.8.diff
cd /home/wwwroot/default/cacti/plugins
tar -zxvf /root/cacti-plugin/monitor-0.8.2.tar.gz
tar -zxvf /root/cacti-plugin/settings-0.5.tar.gz
tar -zxvf /root/cacti-plugin/thold-0.4.3.tar.gz
mysql -u root -p888 cacti < monitor/monitor.sql
mysql -u root -p888 cacti < thold/thold.sql
再次修改Cacti的配置文件:
[root@redhat8 ~]# vi /home/wwwroot/default/cacti/include/config.php