1. Install required packages
# yum -y install httpd php php-mysql php-snmp mysql mysql-server net-snmp
2. Configure MySQL
# /etc/init.d/mysqld start
# mysqladmin --user=root create cacti
# mysql -u root -p
mysql>GRANT ALL on cacti.* TO cacti@localhost IDENTIFIED BY 'password';
mydql>flush privileges;
3. Install and Configure Cacti
# tar xf cacti-0.8.7g.tar.gz
# cp -r cacti-0.8.7g /var/www/html/cacti
# cd /var/www/html/cacti
# mysql cacti < cacti.sql
# vim include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "password";
# useradd -s /sbin/nologin -M cacti
# chown -R cacti.cacti rra/ log/
# crontab -e
*/5 * * * * cacti php /var/www/html/cacti/poller.php > /dev/null 2>&1
注意:可以手动运行php /var/www/html/cacti/poller.php进行测试会发现有多WARNING:
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /var/www/html/cacti/include/global_arrays.php on line 640
解决办法是:
# vim /etc/php.ini
date.timezone = PRC
# /etc/init.d/httpd restart
4. Install and Confiture Spine
# yum -y install automake libtool mysql-devel net-snmp-devel
# tar xf cacti-spine-0.8.7g.tar.gz
# cd cacti-spine-0.8.7g
# aclocal
# libtoolize --force
# autoheader
# autoconf
# automake
# ./configure
# make && make install && echo $?
# cp /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
# vi /usr/local/spine/etc/spine.conf
DB_Host localhost
DB_Database cacti
DB_User cacti
DB_Pass password
DB_Port 3306
DB_PreG 0
5. Install and Configure rrdtool
# yum -y install libxml2-devel pango-devel cairo-devel perl-ExtUtils-MakeMaker
# tar xf rrdtool-1.4.4.tar.gz
# cd rrdtool-1.4.4
# ./configure
# make && make install && echo $?
6. Test and Further Configure
Use firefox to open the url: http://localhost/cacti