一. 环境

平台:CentOS4.5最小安装(只安装开发工具)
更改yum安半源为:mirrors.163.com

1.备份系统原有的CentOS-Base.repo为CentOS-Base.repo.bak
    #cd /etc/yum.repos.d/
    #mv CentOS-Base.repo CentOS-Base.repo.bak
2.更改后的CentOS-Base.repo文件如下:

# CentOS-Base.repo
#
# Replace /etc/yum.repos.d/CentOS-Base.repo with this file will change yum source to CentOS Mirror on TA139
#

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
baseurl=http://mirrors.163.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4

3.定义yum非官方库
    #vi /etc/yum.repo.d/dag.repo
内容如下:
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1

4.导入导入非官方库的GPG
    #rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

二. 相关软件包的安装

#yum -y install mysql-server
#yum -y install cacti

三. 配置

   1. httpd的配置
#vi /etc/httpd/conf/httpd.conf
其实不用百行配置也是可以运行cacti的,我这里进行如下的配置:
(1) 将43行的 ServerTokens OS 改为 ServerTokens Prod (在出现错误页的时候不显示服务器操作系统的名称)  
(2) 将505行 ServerSignature On 中的On改为Off   (在错误页中不显示Apache的版本)
(3) 将236行 ServerAdmin root@localhost 中的root@localhost改为自己的邮箱
(4) 将250行 ServerName 后边的改为自己的主机名并取消注释 (这个地方不改启动apache会报一个错)
(5) 将305行 Options Indexes FollowSymLinks改为Options Includes ExecCGI FollowSymLinks (允许服务器执行CGI及SSI,不在浏览器上显示树状目录结构)
(6) 将731行 AddDefaultCharset UTF-8 改为AddDefaultCharset GB2312 (添加GB2312为默认编码)
(7) 将523行 Options Indexes MultiViews中的Indexes去掉 (不在浏览器上显示树状目录结构)
         #vi /etc/httpd/conf.d/cacti.conf
在第9行      allow from 127.0.0.1下边一行为:allow from 192.168. (注:这个要看你所在的网段)
   2. net-snmp的配置
#vi /etc/snmp/snmpd.conf
(1) 将41行改为 com2sec notConfigUser   localhost        public
(2) 将62行改为 access   notConfigGroup ""       any        noauth     exact   all none none
(3) 将85行的注释去掉后为:view all     included   .1                                80
   3. mysqld的配置
#service mysqld start
#mysql -uroot
mysql>delete from mysql.user where user='';
mysql>set password for root@localhost=password("rootpw");
mysql>create database cactidb;
mysql>grant all on cactidb.* to root@localhost;
mysql>grant all on cactidb.* to cacti@localhost;
mysql>set password for cacti@localhost=password("cactipw");
mysql>select user,host,password from mysql.user;
mysql>show databases
mysql>exit
   4. cacti的配置
#cd /var/www/cacti
#mysql --user=root --password=rootpw cactidb < cacti.sql
#vi include/config.php
更改27行为 $database_default = "cactidb";
更改29行为 $database_username = "cacti";
更改30行为 $database_password = "cactipw";

   #chown cacti rra/ log/
   5. cron自动化的配置
#vi /etc/crontab
在最后加如下一行:*/5 * * * * cacti /usr/bin/php /var/www/cacti/poller.php > /dev/null 2>&1
   6. 设置相关的服务开机自动启动
#chkconfig snmpd on
#chkconfig httpd on
#chkconfig mysqld on
四. 重启相关的服务
  
   #service httpd restart
   #service snmpd restart
   #service mysqld restart
五. 打开cacti
http://192.168.32.200/cacti/
   NEXT-->FINISH
后记: 大约十分钟后可以出图。