Cacti安裝配置文檔
1.安裝環(huán)境:RedHat AS 5.4
2.安裝Apache、MySQL(見apache,mysql安裝文檔)
安裝PHP:
先安裝zlib,freetype,libpng,jpeg 以便于讓PHP 支持GD 庫( Cacti 的WeatherMap插件必須要GD 庫的支持)
1).安裝zlib
#cd /usr/local/src/tarbag/
#wget http://
#tar zxvf zlib-1.2.3.tar.gz -C ../software/
# cd ../software/zlib-1.2.3/
#./configure --prefix=/usr/local/zlib
#make
#make install
2).安裝libpng
# cd /usr/local/src/tarbag/
#wget http://
#tar zxvf libpng-1.2.16.tar.gz -C ../software
# cd ../software/libpng-1.2.16/
#./configure
#make
#make install
注意,這里的makefile 不是用./configure 生成,而是直接從scripts/里拷一個
3)安裝freetype
# cd /usr/local/src/tarbag/
#wget http://
#tar zxvf freetype-2.3.4 .tar.gz -C ../software
# cd ../software/freetype-2.3.4/
#./configure --prefix=/usr/local/freetype
#make
#make install
4).安裝Jpegtar -zxf jpegsrc-1.v6b.tar.gz
# cd /usr/local/src/tarbag/
#wget http://
#tar zxvf jpegsrc.v6b.tar.gz -C ../software/
# cd ../software/jpeg-6b/mkdir /usr/local/libjpeg
#mkdir -p /usr/local/libjpeg/include
#mkdir /usr/local/libjpeg/bin
#mkdir /usr/local/libjpeg/lib
#mkdir /usr/local/libjpeg/man
#mkdir /usr/local/libjpeg/man/man1//可以用mkdir -p /usr/local/libjpeg/man/man1 一步創(chuàng)建多層目錄
#./configure --prefix=/usr/local/libjpeg --enable-shared --enable-static
#make && make install注意,這里configure 一定要帶--enable-shared 參數(shù),不然,不會生成共享庫需要安裝安裝libxml 包,但版本太低,PHP5 需要更高版本的libxml 包。
# cd /usr/local/src/tarbag/
#wget http://
#tar –zxvf libxml2-2.6.25.tar.gz -C ../software
# cd ../software/libxml2-2.6.25
# ./configure
# make
# make install
6).安裝GD
# cd /usr/local/src/tarbag/
#wget http://
# tar zxvf gd-2.0.33.tar.gz -C ../software/
# cd ../software/gd-2.0.33/
#./configure --prefix=/usr/local/libgd --with-png --with-freetype=/usr/local/freetype --with-jpeg=/usr/local/libjpeg
#make
#make install
編譯時顯示以下信息:
** Configuration summary for gd 2.0.34:
Support for PNG library: yes
Support for JPEG library: yes
Support for Freetype 2.x library: yes
Support for Fontconfig library: yes
Support for Xpm library: no
Support for pthreads: yes
7).編輯/etc/ld.so.conf,添加以下幾行到此文件中。
/usr/local/zlib/lib
/usr/local/freetype/lib
/usr/local/libjpeg/lib
/usr/local/libgd/lib
并執(zhí)行l(wèi)dconfig 命令,使用動態(tài)裝入器裝載找到共享庫
8).安裝PHP
# cd /usr/local/src/tarbag/
#wget http://
#tar -zxvf php-5.2.10.tar.gz -C ../software
#cd ../software/php-5.2.10
#./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-gd=/usr/local/libgd --enable-gd-native-ttf --with-ttf --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/libjpeg --with-png-dir=/usr --with-zlib-dir=/usr/local/zlib --enable-xml --enable-mbstring --enable-sockets --with-libxml-dir=/usr/local
#注:如果出現(xiàn)configure: error: cannot find output from lex; giving up,從光盤安裝flex包即可解決。-
# make
# make install
# ln –s /usr/local/php5/bin/* /usr/local/bin/
# vi /usr/local/apache/conf/httpd.conf
AddType application/x-httpd-php .php
修改DirectoryIndex 行,添加index.php修改為
DirectoryIndex index.php index.html index.html.var
# vi /usr/local/apache2/htdocs/index.php
添加以下行:
Phpinfo();
?>
wq 保存退出。
對php 編譯選項(xiàng)的解釋:
--prefix=/usr/local/php //指定PHP 的安裝目錄
--with-apxs2=/usr/local/apache2/bin/apxs //支持Apache 模塊
--with-mysql=/usr/local/mysql //支持MySQl
--with-gd=/usr/local/libgd //支持GD 庫
--enable-gd-native-ttf //激活對本地TrueType 字符串函數(shù)的支持
--with-ttf //激活對FreeType 1.x 的支持
--with-freetype-dir=/usr/local/freetype //激活對FreeType 2.x 的支持
--with-jpeg-dir=/usr/local/libjpeg //激活對jpeg-6b 的支持
--with-png-dir //激活對png 的支持
--with-zlib-dir=/usr/local/zlib//激活對zlib 的支持
--enable-mbstring //激活mbstring 模塊
--with-mail //支持Mail 函數(shù)
--enable-xml //支持XML--enable-sockets //支持套接字
3. 安裝RRDTool
由于rrdtool-1.2.23 需要一些庫文件支持,故需先安裝配置支持的環(huán)境,然后編譯安裝。
需要的包:cgilib-0.5.tar.gz、zlib-1.2.3.tar.gz、libpng-1.2.18.tar.gz、freetype-2.3.5.tar.gz、libart_lgpl-2.3.17.tar.gz、rrdtool-1.2.23.tar.gz tar zxf cgilib-0.5.tar.gz
安裝zlib
# cd /usr/local/src/software/zlib-1.2.3/
#./configure --prefix=/usr/local/rrdtool/lb
#make
#make install
安裝libpng
# cd /usr/local/src/software/libpng-1.2.16/
#./configure --disable-shared --prefix=/usr/local/rrdtool/lb
#make
#make install
安裝freetype
# cd /usr/local/src/software/freetype-2.3.4/
#./configure --disable-shared --prefix=/usr/local/rrdtool/lb
#make
#make install
rmdir: /usr/local/rrdtool/lb//include/freetype2/freetype/internal: 沒有那個文件或目錄
make: [install] 錯誤 1 (忽略)
Make install 過程會報這個錯.直接忽略.
安裝libart_lgpl
# cd /usr/local/src/tarbag/
# wget http://
# tar jxvf libart_lgpl-2.3.17.tar.bz2 -C ../software/
# cd ../software/libart_lgpl-2.3.17/
#./configure --disable-shared --prefix=/usr/local/rrdtool/lb
#make
#make install
安裝intltool
# cd /usr/local/src/tarbag/
# wget http://
# tar jxvf intltool-0.40.6.tar.bz2 -C ../software/
# cd ../software/intltool-0.40.6/
#./configure
#make
#make install
編譯過程會報這個錯:checking for XML::Parser... configure: error: XML::Parser perl module is required for intltool
安裝perl-XML-Parser
# cd /usr/local/src/tarbag
# wget http://
# tar zxvf XML-Parser-2.34.tar.gz -C ../software/
# cd ../software/XML-Parser-2.34/
# perl Makefile.PL
# make
# make install
安裝完XML-Parser再回去重編譯intltool
# cd /usr/local/src/software/intltool-0.40.6/
#./configure
# make
# make install
安裝rrdtool
# cd /usr/local/src/tarbag
# wget http://
# tar zxvf rrdtool-1.4.3.tar.gz -C ../software/
# cd ../software/rrdtool-1.4.3/
#./configure --prefix=/uar/local/rrdtool --disable-tcl
# make
# make install
4. 安裝net-snmp
#cd /usr/local/src/tarbag/
#wget http://
# tar zxvf net-snmp-5.2.4.tar.gz -C ../software
#cd ../software/net-snmp-5.2.4
#./configure --prefix=/usr/local/net-snmp --enable-developer
#make
#make install
# ln –s /usr/local/net-snmp/bin/* /usr/local/bin/
#cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmpd.conf
修改/usr/local/net-snmp/share/snmp/snmpd.conf文件的61和62行,設(shè)置可以訪問改SNMP的網(wǎng)段以及community名稱。
比如設(shè)置為
com2sec local localhost public
com2sec mynetwork 192.168.100.0/24 public
# /usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf
啟動SNMP 服務(wù)
# vi /etc/rc.d/rc.local
//在rc.local 上加入一行
/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf
系統(tǒng)啟動時啟動SNMP服務(wù)。
5. 安裝Cacti
#cd /usr/local/src/tarbag
#wget http://
# tar zxvf cacti-0.8.7e.tar.gz
# mv cacti-0.8.7e /usr/loca/apache2/htdocs/cacti
# vi /usr/local/apache2/htdocs/cacti/include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
//添加cacti 用戶
# useradd cacti
//將rra 目錄的所有權(quán)給cacti 用戶
# chown –R cacti /usr/local/apache/2htdocs/cacti/rra
//修改cacti 目錄所屬組
# chgrp –R cacti /usr/loca/apache2/htdocs/cacti
//添加cron 任務(wù)
*/1 * * * * /usr/local/bin/php /usr/local/apache2/htdocs/cacti/poller.php > /dev/null 2>&1
數(shù)據(jù)庫配置
cp /usr/local/apache2/htdoces/cacti/cacti.sql /tmp/1.sql
mysql> show databases;
mysql> create database cacti;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cacti |
| mysql |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> use cacti
Database changed
mysql> source /tmp/2.sql
mysql> exit
Bye
#ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so.15.0.0 /usr/lib/libmysqlclient.so.15
#ldconfig這兩句要加上,否則系統(tǒng)無法找到libmysqlclient.so.15庫(版本不同libmysqlclient.so.的名字也不同)
Chmod 777 /usr/local/apache/htdocs/cacti/log
Chmod 777 /usr/local/apache/htdocs/cacti/rra
8. 完成cacti 的安裝
2)默認(rèn)用戶名:admin 密碼:admin
這是監(jiān)控服務(wù)器的一部分圖:
僅僅初步安裝Cacti后,是不支持插件的,要先安裝cacti的一個patch--Plugin Architecture!
PA與cacti版本的關(guān)系:
PA 1.0 = cacti 0.8.6i
PA 1.1 = cacti 0.8.6i et 0.8.6j
PA 2.0 = cacti 0.8.7b
PA 2.2 = cacti 0.8.7c
PA 2.4 = cacti 0.8.7d
PA 2.5 = cacti 0.8.7e
patch-plugin Arch的安裝:
本文是針對cacti 0.8.7e版本的插件安裝筆記,所以對應(yīng)的是PA2.5.
[root@centos53 cacti]# cd /usr/local/src/tarbag/
[root@centos53 src]# wget http://
[root@centos53 src]# unzip cacti-plugin-0.8.7e-PA-v2.5.zip -d cacti-plugin-0.8.7e
[root@centos53 src]# cp -R cacti-plugin-0.8.7e/* /usr/local/apache2/htdocs/cacti
[root@centos53 src]# cd /usr/local/apache2/htdocs/cacti
[root@centos53 cacti]# cp pa.sql /tmp/2.sql
mysql> show databases;
mysql> create database cacti;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cacti |
| mysql |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> use cacti
Database changed
mysql> source /tmp/2.sql
mysql> exit
[root@centos53 cacti]# patch -p1 -N
[root@centos53 cacti]# vi /var/www/cacti/include/global.php
/* Default database settings*/
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "root";
$database_password = "";
$database_port = "3306";
/*
Edit this to point to the default URL of your Cacti install
would be set to /cacti/
*/
$config['url_path'] = '/cacti/';
授權(quán)admin用戶"plugin Management":
登錄后,Utilities--User Management--admin--Realm Permissions,選中“Plugin Management",Save。
NTop的安裝以及與Cacti的結(jié)合
安裝cacti的ntop接口
# cd /usr/local/src/tarbag
# wget http://
# tar zxvf ntop-0.1.tar.gz
# mv ntop-0.1/ /usr/local/apache2/htdocs/cacti/plugins/
# vi /usr/local/apache2/htdocs/cacti/include/global.php //在cacti面板上添加ntop接口
$plugins = array();
$plugins[] = 'ntop';
在cacti面板上打開User Management 選擇admin用戶,將View NTop勾打上 點(diǎn)擊save.
這樣在cacti面板top欄就出現(xiàn)了ntop的接口
安裝ntop程序
先安裝Cgilib
# cd /usr/local/src/tarbag/
# wget http://
# tar zxvf cgilib-0.5.tar.gz -C ../software
# cd ../software/cgilib-0.5/
# make
# cp libcgi.a /usr/lib
# cp cgi.h /usr/include
安裝libgd
# cd /usr/local/src/tarbag/
# wget http://
# tar zxvf gd-2.0.33.tar.gz -C ../software/
# cd ../software/gd-2.0.33
# ./configure --prefix=/usr/local/libgd
# make
# make install
安裝pcap庫
#cd /usr/local/src/tarbag/
#wget http://
#rpm -ivh libpcap-devel-0.9.4-14.el5.i386.rpm
安裝Ntop
# cd /usr/local/src/tarbag/
# wget http://
# tar zxvf ntop-3.2.tgz -C ../software/
# cd ../software/ntop-3.2
# ./configure --prefix=/usr/local/ntop --with-gd-root=/usr/local/libgd/ --with-gd-lib=/usr/local/libgd/lib/ --with-gd-include=/usr/local/libgd/include/
# make
# make install
# cp packages/RedHat/ntop.conf.sample /usr/local/ntop/etc/ntop.conf
# useradd ntop
# chown -R ntop:ntop /usr/local/ntop/
NTop配置文件
[root@centos53 /]# vi /usr/local/ntop/etc/ntop.conf
--interface eth0,lo //#eth0 是我的單塊網(wǎng)卡 lo是回路
--local-subnets 192.168.10.0/24 //#由于我只是一臺機(jī)器所以下面的沒加,如果您是在路由器或網(wǎng)關(guān)上請把對應(yīng)的ip段改成自己的
--http-server 3000 //運(yùn)行端口
--db-file-path /usr/local/ntop/var/log //數(shù)據(jù)庫存放路徑
--daemon //守護(hù)進(jìn)程方式運(yùn)行
--user ntop //用戶名
--trace-level 3 //默認(rèn)運(yùn)行等級
--disable-schedyield //跳過所有錯誤
NTop第一次啟動
第一次運(yùn)行說明:第一次啟動前用下面的命令設(shè)置一個管理密碼,以后web頁面設(shè)置的時候用得到。用戶名默認(rèn)admin,密碼就是下面的命令設(shè)置的。
#/usr/bin/ntop -P -u -A
-P [directory]指定數(shù)據(jù)庫存放路徑
-u [user]指定service啟動user
-A 設(shè)定admin密碼,ntop會內(nèi)建admin管理者賬號于ntop中
如:
# /usr/local/ntop/bin/ntop -P /usr/local/ntop/var/log/ -u ntop -A
Fri Nov 13 14:36:23 2009 NOTE: Interface merge enabled by default
Fri Nov 13 14:36:23 2009 Initializing gdbm databases
ntop startup - waiting for user response!
Please enter the password for the admin user: admin
Please enter the password again: admin
Fri Nov 13 14:37:09 2009 Admin user password has been set
以上操作ntop初始化就完成了。
啟動運(yùn)行
#/usr/local/ntop/bin/ntop -P /usr/local/ntop/var/log/ -u ntop &
或加入啟動腳本(若找不到網(wǎng)絡(luò)設(shè)備可用 -i eth0 項(xiàng)指定!)
# echo "/usr/local/ntop/bin/ntop -P /usr/local/ntop/var/log/ -u ntop &" >>/etc/rc.d/rc.local
瀏覽