来自http://os.51cto.com/art/201104/252883.htm
内容基本上一样,主要是想记录下自己在安装的过程中遇到的一些问题和一些与原文有出入的地方,方便以后安装。
1、首先要安装Apache+PHP+MySQL+Net-SNMP+RRDTool(MySQL安装、Apache安装、PHP安装),本文采用YUM命令安装所有cacti依赖软件。过程如下:
- #yum install mysql mysql-server mysql-devel php-mysql httpd php php-pdo lm_sensors net-snmp net-snmp-devel openssl-devel php-snmp net-snmp-utils perl-Net-Daemon perl-PlRPC perl-DBI rrdtool perl-rrdtool perl-DBD-MySQL net-snmp-libs
安装cacti-spine需要用到这几个包net-snmp-devel mysql mysql-devel openssl-devel
2、配置SNMP
- #vi /etc/snmp/snmp.conf (原文)
- #vi /etc/snmp/snmpd.conf (实际)
将下边这行中的default 改为127.0.0.1
- com2sec notConfigUser default public
- com2sec notConfigUser 127.0.0.1 public
将下边这行中的systemview 改为all
- access notConfigGroup "" any noauth exact systemview none none
- access notConfigGroup "" any noauth exact all none none
将下边这行的注释"#"号去掉
- #view all included .1 80
- view all included .1 80
启动snmpd/httpd/mysql服务
- #service snmpd start
- #service httpd start
- #service mysqld start
3、下载cacti:
4、在数据库中建库、授权、导入数据库结构
- #wget http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz
- #tar -zvxf cacti-0.8.7g.tar.gz
- #mv cacti-0.8.7g /var/www/html/cacti
- #mysql -u root
- mysql> create database cacti;
- mysql> grant all privileges on cacti.* to cacti@localhost identified by 'cacti' with grant option;
- mysql> grant all privileges on cacti.* to cacti@127.0.0.1 identified by 'cacti' with grant option;
- mysql> use cacti;
- mysql> source /var/www/html/cacti/cacti.sql;
配置cacti以连接数据库
- #vi /var/www/html/cacti/include/config.php
- $database_type = "mysql";
- $database_default = "cacti";
- $database_hostname = "localhost";
- $database_username = "cacti";
- $database_password = "cacti";
- $database_port = "3306";
5、添加cacti用户,否则cacti不能写入rrd和log目录,将会无法生成图片
- #useradd cacti -d /var/www/html/cacti -s /bin/false
- #chown -R cacti /var/www/html/cacti/rra /var/www/html/cacti/log
6、增加入一个计划任务,使得 cacti 每两分钟生成一个监控图表。注意poller.php路径
- #crontab -e
- */2 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1
7、完成cacti最后的配置,在浏览器输入:http://localhost/cacti