构建cacti检测系统
        (Yang120jun@qq.com)
目录
 
安装支持软件
以下软件包需要依赖关系,所以使用本地yum源进行安装 注:挂载光盘不要自动挂载
本地yum源配置方法
[root@localhost ~]#vim /etc/yum.repos.d/yangjun.repo
[rhel]
name=redhat
baseurl=file:///media/Server
enabled=1
gpgcheck=0
使用方法 yum –y install httpd-2.2.3-31.el5.i386.rpm
 
(1)   安装数据库和WEB平台
httpd-2.2.3-31.el5.i386.rpm
mysql-5.0.22-21
mysql-server-5.0.77-3.el5.i386.rpm
mysql-connector-odbc-3.51.26r1127-1.el5.i386.rpm
php-5.1.6-23.2.el5_3.i386.rpm
php-mysql-5.1.6-23.2.el5_3.i386.rpm
php-common-5.1.6-23.2.el5_3.i386.rpm
php-pdo-5.1.6-23.2.el5_3.i386.rpm
(2)   启动mysql http 并开机启动
[root@localhost ~]#/etc/init.d/httpd start
[root@localhost ~]#service mysqld start
[root@localhost ~]#chkconfig httpd on
[root@localhost ~]#chkconfig mysqld on
 (3)   安装net-snmp-utils软件包
       依次安装lm_sensors ,net-snmp, net-snmp-utils
 (4)   安装rrdtool 软件包
       解压软件包 [root@localhost ~]#tar zxvf rrdtool****
       [root@localhost ~]#cd rrdtool-1.2.27
[root@localhost ~]#./configure --prefix=/usr/local/
[root@localhost ~]#make && make install
5) 安装配置cacti 服务器套件
       软件包下载(英文源码包 http://www.cacti.net/downloads/cacti-0.8.7b.tar.gz
       将下载好的cacit文件包解压至/var/www/html/ 下
tar zxvf cacti.***.tar.gz -C /var/www/html
添加cacti 账户给相应的权限
[root@localhost ~]#cd /var/www/html
[root@localhost ~]#mv cacti-8.*** cacti
[root@localhost ~]#useradd cactiuser
[root@localhost ~]#chown -R cactiuser.cactiuser cacti/rra/ cacti/log/
  6)设置检测数据库
       mysql -u root 登陆数据库
       创建数据并设置默认字符集~用户名和密码
       mysql>CREATE DATABASE cactidb DEFAULT CHARACTER SET utf8;
mysql>GRANT all ON cactidb.* TO cactiuser@localhost IDENTIFIED BY 'pwd@123';
mysql>QUIT
[root@localhost ~]#mysql -u cactiuser -p cactidb < cacti/cacti.sql 导入数据表
输入密码pwd@123
(7)  调整cacti配置文件、
    [root@localhost ~]#cd /var/www/html/cacti/
    [root@localhost ~]#vim include/config.php
$database_type = "mysql";
$database_default = "cactidb"; 数据库名称
$database_hostname = "localhost"; 授权地址
$database_username = "cactiuser"; 授权用户
$database_password = "pwd@123"; 授权密码
$database_port = "3306"; 数据库服务端口
   (8) 调整httpd设置并重启服务
       [root@localhost ~]#vim /etc/httpd/http.conf
listen 80 监听端口
DocumentRoot "/var/www/html/cacti" 设置网站文件根目录
<Directory "/var/www/html/cacti"> 设置权限
Options none
llowOverride None
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.php index.html 默认索引页
AddDefaultCharset UTF-8 设置默认字符集
重启http服务
[root@localhost ~]#/etc/init.d/httpd restart
(9)设置每5分钟采集一次数据
[root@localhost ~]#crontab -u cactiuser -e
[root@localhost ~]#service crond restart
[root@localhost ~]#chkconfig crond on
(10) 初始化cacti系统
        访问http://127.0.0.1/
        admin admin 初始用户名和密码 首次登陆需要更改新密码
1)所需软件包 snmp
lm_sensors-2.10.7-4.el5.i386.rpm
net-snmp-5.3.2.2-7.el5.i386.rpm
2)配置启动snmp
修改/etc/snmp/snmpd.conf
41行 com2sec notConfigUser 192.168.0.1       publicsvr
62行 access notConfigGroup ""      any       noauth    exact all none none
85行view all    included .1                               80
开启服务 service snmpd start
设置开机加载 chkconfig snmpd on
   
(1)如果安装中文cacti需要设置RRDTOOL工具版本和字体路径还有操作系统的中文支持
1、配置 -> 设置 -> 可视化 -> 最大域长度 80
2、设备 -> 选择要更改的设备 -> 相关数据查询 -> SNMP - 接口统计 -> (查询明细) ->保存
                 第一
                 第二
                 第三