天天看點

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 配置

[root@jw01 ~]# 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 

[root@jw01 ~]# cd /etc/httpd/conf.d/                      ****配置虛拟主機域名********

[root@jw01 conf.d]# vim vhosts.conf                      ******自己設定的檔案,添加****

<VirtualHost *:80>

    DocumentRoot /var/www/html/cacti

    ServerName cacti.yoohouse.com

</VirtualHost>                        

[root@jw01 ~]# service httpd start

之後我們在我們webmin裡面配置了一個cacti.yoohouse.com域名,OK,等下面的全部配置完成之後,就可以本地的浏覽器登入;

3.2、 Mysql

[root@jw01 ~]# rpm -qa |grep mysql

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 

[root@jw01 ~]#  service mysqld start

[root@jw01 ~]#  mysqladmin -uroot password 123456

[root@jw01 ~]#  mysqladmin --user=root --password reload

3.3、 PHP

[root@jw01 ~]# 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-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 安裝

[root@jw01 ~]# rpm -qa |grep rrdtool

perl-rrdtool-1.4.7-1.el5.rf

rrdtool-1.4.7-1.el5.rf 

[root@jw01 ~]# yum -y install rrdtool

3.5、 net-snmp 安裝及配置

[root@jw01 ~]# 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-5.3.2.2-20.el5 

3.5.1、net-snmp配置檔案修改

[root@jw01 ~]# 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

[root@jw01 ~]# service snmpd start

[root@jw01 ~]# 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

[root@jw01 ~]# tar -zxvf cacti-0.8.8a.tar.gz 

[root@jw01 ~]# mv cacti-0.8.8a  cacti

[root@jw01 ~]# mv cacti /var/www/html/

3.6.2、建立使用者cacti

[root@jw01 ~]# useradd cacti

[root@jw01 ~]# passwd cacti

3.6.3、建立cacti資料庫/導入cacti資料

[root@jw01 ~]# cd /var/www/html/cacti/

[root@jw01 cacti]# pwd

/var/www/html/cacti

[root@jw01 cacti]# mysqladmin --user=root -p create cacti

[root@jw01 cacti]# mysql -uroot -p cacti < cacti.sql 

3.6.4、 進入資料庫給使用者授權

mysql -uroot -p

3.6.5、 配置cacti的配置檔案

[root@jw01 cacti]# vim  include/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

   would be set to /cacti/

*/

$url_path = "/";    //cacti路徑

/* Default session name - Session name must contain alpha characters */

//$cacti_session_name = "Cacti"; 

3.6.7、 設定目錄權限

[root@jw01 cacti]# chown -R cactiuser rra/ log/

3.6.8、 配置任務計劃

[root@jw01 cacti]# echo "*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1">>/etc/crontab

[root@jw01 cacti]#  service crond restart

四、IE登入設定

4.2、設定cacti的路徑:如圖

<a target="_blank" href="http://blog.51cto.com/attachment/201304/155721121.jpg"></a>

4.3、完成之後使用者登入:

預設使用者名和密碼:cacti/cacti

提示你修改密碼;

<a target="_blank" href="http://blog.51cto.com/attachment/201304/155957376.jpg"></a>

本文轉自 kuangling 51CTO部落格,原文連結:http://blog.51cto.com/kling/1180778