1.安装LAMP环境
这里就不做介绍,网上一堆的相关文档,还有很多牛人写的自动化安装脚本

2.安装rrdtool
yum install cairo-devel libxml2-devel pango pango-devel rrdtool –y

3.安装SNMP
操作系统一般自带SNMP,如果没有即安装

yum -y install net-snmp net-snmp-libs net-snmp-utils

4.安装Cacti

(1)下载Cacti
#wget http://www.cacti.net/downloads/cacti-0.8.8b.tar.gz

#tar -zxfv cacti-0.8.8b.tar.gz

#mv cacti-0.8.8b /var/www/html/cacti

#cd /var/www/html/cacti/

(2)初始化数据库
创建数据库
mysql> create database nagios default character set utf8;

mysql> grant all privileges on nagios.* to 'nagios'@'localhost' identified by 'XXXX' with grant option;

mysql> grant all privileges on nagios.* to 'nagios'@'%' identified by 'XXXX' with grant option;

mysql> flush privileges;

初始化数据库
#mysql -unagios -p nagios
(3)配置连接信息

#cd /var/www/html/cacti/
#vim include/config.php

$database_type = "mysql";
$database_default = "nagios";
$database_hostname = "127.0.0.1";
$database_username = "nagios";
$database_password = "XXXX";
$database_port = "3306";
$database_ssl = false;

(4)设置目录权限
# useradd cactiuser
# chown -R cactiuser rra/ log/

(5)增加定时任务
#echo "*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1">>/etc/crontab
#每5分钟以cactier去抓取数据绘图,这个时间5分钟应该是最小间隔了,不建议修改为更小值。
#service crond restart
#service httpd restart

访问 http://172.18.1.113/cacti

刚开始访问没有数据图可以执行以下操作,一定要使用cactiuser,否则正常定时任务没有权限写入文件
# su - cactiuser
#php  /var/www/html/cacti/poller.php > /dev/null 2>&1