cacti 安装与配置
一、cacti概述1. cacti是用php语言实现的一个软件,它的主要功能是用snmp服务获取数据,然后用rrdtool储存和更新数据,当用户需要查看数据的时候用rrdtool生成图表呈现给用户。因此,snmp和rrdtool是cacti的关键。Snmp关系着数据的收集,rrdtool关系着数据存储和图表的生成。
2. Mysql配合PHP程序存储一些变量数据并对变量数据进行调用,如:主机名、主机ip、snmp团体名、端口号、模板信息等变量。
3. snmp抓到数据不是存储在mysql中,而是存在rrdtool生成的rrd文件中(在cacti根目录的rra文件夹下)。rrdtool对数据的更新和存储就是对rrd文件的处理,rrd文件是大小固定的档案文件(Round Robin Archive),它能够存储的数据笔数在创建时就已经定义。
二、系统环境
1、CentOS release 5.6 _64x
三、软件安装及配置
3.1、Apache 配置
# rpm -qa |grep httpd
httpd-manual-2.2.3-45.el5.centos
httpd-2.2.3-45.el5.centos
system-config-httpd-1.3.3.3-1.el5
# cd /etc/httpd/conf.d/ ****配置虚拟主机域名********
# vim vhosts.conf ******自己设置的文件,添加****
ServerAdmin kuangl@orient-media.com
DocumentRoot /var/www/html/cacti
ServerName cacti.yoohouse.com
# service httpd start
之后我们在我们webmin里面配置了一个cacti.yoohouse.com域名,OK,等下面的全部配置完成之后,就可以本地的浏览器登录;
3.2、 Mysql
# rpm -qa |grep mysql
mysql-5.0.77-4.el5_5.4
mysql-5.0.77-4.el5_5.4
mysql-server-5.0.77-4.el5_5.4
mysql-connector-odbc-3.51.26r1127-1.el5
php53-mysql-5.3.3-13.el5_8
libdbi-dbd-mysql-0.8.1a-1.2.2
#service mysqld start
#mysqladmin -uroot password 123456
#mysqladmin --user=root --password reload
3.3、 PHP
# rpm -qa |grep php
php53-devel-5.3.3-13.el5_8
php53-snmp-5.3.3-13.el5_8
php53-xml-5.3.3-13.el5_8
php53-common-5.3.3-13.el5_8
php53-5.3.3-13.el5_8
php53-mysql-5.3.3-13.el5_8
php53-intl-5.3.3-13.el5_8
php53-sqlite2-5.3.2-12042713
php53-bcmath-5.3.3-13.el5_8
php53-pspell-5.3.3-13.el5_8
3.4、 rrdtool 安装
# rpm -qa |grep rrdtool
perl-rrdtool-1.4.7-1.el5.rf
rrdtool-1.4.7-1.el5.rf
# yum -y install rrdtool
3.5、 net-snmp 安装及配置
# rpm -qa |grep snmp
net-snmp-utils-5.3.2.2-20.el5
net-snmp-perl-5.3.2.2-20.el5
net-snmp-libs-5.3.2.2-20.el5
net-snmp-devel-5.3.2.2-20.el5
net-snmp-libs-5.3.2.2-20.el5
php53-snmp-5.3.3-13.el5_8
net-snmp-devel-5.3.2.2-20.el5
net-snmp-5.3.2.2-20.el5
3.5.1、net-snmp配置文件修改
# vim /etc/snmp/snmpd.conf
将#view systemview included .1.3.6.1.2.1.1
#view systemview included .1.3.6.1.2.1.25.1.1
修改view systemview included .1.3.6.1.2.1
3.5.2、测试net-snmp
# service snmpd start
# snmpwalk -v 1 -c public localhost .1.3.6.1.2.1
SNMPv2-MIB::sysDescr.0 = STRING: Linux cronos 2.4.28 #2 SMP ven jan 14 14:12:01 CET 2005 i686
3.6、 cacti 安装及配置
3.6.1、下载cacti
# wget http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz
# tar -zxvf cacti-0.8.8a.tar.gz
# mv cacti-0.8.8acacti
# mv cacti /var/www/html/
3.6.2、创建用户cacti
# useradd cacti
# passwd cacti
3.6.3、创建cacti数据库/导入cacti数据
# cd /var/www/html/cacti/
# pwd
/var/www/html/cacti
# mysqladmin --user=root -p create cacti
# mysql -uroot -p cacti < cacti.sql
3.6.4、 进入数据库给用户授权
# mysql -uroot -p
mysql> grant all on cacti.* to cacti@localhost identified by "cacti";
mysql> flush privileges;
3.6.5、 配置cacti的配置文件
# viminclude/config.php
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
$database_ssl = false;
/* load up old style plugins here */
$plugins = array();
//$plugins[] = 'thold';
/*
Edit this to point to the default URL of your Cacti install
ex: if your cacti install as at http://serverip/cacti/ this
would be set to /cacti/
*/
$url_path = "/"; //cacti路径
/* Default session name - Session name must contain alpha characters */
//$cacti_session_name = "Cacti";
3.6.7、 设置目录权限
# chown -R cactiuser rra/ log/
3.6.8、 配置任务计划
# echo "*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1">>/etc/crontab
#service crond restart
四、IE登录设置
4.1、在浏览器中输入:http://cacti.yoohouse.com/
4.2、设置cacti的路径:如图
http://blog.运维网.com/attachment/201304/155636641.jpg
http://blog.运维网.com/attachment/201304/155721121.jpg
http://blog.运维网.com/attachment/201304/155744607.jpg
4.3、完成之后用户登录:
默认用户名和密码:cacti/cacti
提示你修改密码;
http://blog.运维网.com/attachment/201304/155957376.jpg
页:
[1]