Chinaunix首页 | 论坛 | 博客
  • 博客访问: 10645200
  • 博文数量: 2905
  • 博客积分: 20098
  • 博客等级: 上将
  • 技术积分: 36298
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-23 05:00
文章存档

2012年(1)

2011年(3)

2009年(2901)

分类: LINUX

2009-03-23 11:19:15

CACTI网络监控安装与使用手册
一.   CACTI介绍
cacti其实是一套php程序,它运用snmpget采集数据,使用rrdtool绘图,使用CACTI,能对大型网络内的PC,SERVER,网络设备的流量,内存,CUP,磁盘空间进行集中化的管理,安装和应用都比较简单。
 
二.CACTI的安装需求 
首先,我们在安装的过程中需要具有以下安装包
操作系统:REDHAT AS4.0
 
数据库:Mysql4.17或以上
 
Web_server:apache 2.0以上版本
 
WEB语言:PHP4.3.10以上版本
 
绘图工具:RRDTOOL
 
数据采集:net-snmp
 
三.安装步骤
以下我是通过编译的办法安装所有所需的软件包,大家可能要问为什么不直接通过RPM包进行安装,因为我个人觉得,通过RPM包安装虽然快捷,不过不利于管理,因此我还是选择了编译的办法。
 
首先把所有的安装包下载来存放在/CACTI的目录下,便于管理安装包
 
下面我们开始mysql数据库的安装
命令格式如下:
 
cd /cacti
 
tar -zxvf mysql*
 
cd mysql*
 
./configure --prefix=/usr/local/mysql
 
Make
 
make install
 
groupadd mysql
 
useradd -g mysql mysql
 
scripts/mysql_install_db
 
chown -R root /usr/local/mysql

chown -R mysql /usr/local/mysql/var
 
chgrp -R mysql /usr/local/mysql
 
rm -f /etc/my.cnf
 
cp support-files/my-medium.cnf /etc/my.cnf
(如果不复制该文件,则无法启动mysql服务)
 
echo /usr/local/mysql/lib/mysql >> /etc/ld.so.conf
echo /usr/local/lib >> /etc/ld.so.conf
 
ldconfig –v
 
cp support-files/mysql.server /etc/init.d/mysql
/usr/local/mysql/bin/mysqld_safe --user=mysql &
 
cd /etc/rc3.d/
 
ln -s ../init.d/mysql S85mysql
 
ln -s ../init.d/mysql K85mysql
 
cd /etc/rc5.d/
 
ln -s ../init.d/mysql S85mysql
 
ln -s ../init.d/mysql K85mysql
 
cd /etc/init.d/
 
chmod 755 mysql
 
然后我们开始安装apache
命令格式如下:
 
cd /cacti
 
tar -zxvf httpd*
 
cd httpd*
 
./configure --prefix=/usr/local/http
 
Make
 
make install
 
cd /usr/local/http/bin
 
cp apachectl /etc/init.d/httpd
 
cd /etc/rc3.d/
 
ln -s ../init.d/httpd S85httpd
 
ln -s ../init.d/httpd K85httpd
 
cd /etc/rc5.d/
 
ln -s ../init.d/httpd S85httpd
 
ln -s ../init.d/httpd K85httpd
 
/usr/local/http/bin/apachectl start
 
最重要的一步,安装PHP
命令格式:
cd /cacti
 
tar -zxvf php*
 
cd php*
 
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/http/bin/apxs --with-config-filepath=/Usr/local/php --enable-sockets --with-mysql=/usr/local/mysql --with-zlibdir=/usr/include –with-gd
 
Make
 
make install(如果编译不成功,那还需继续找原因排错,直到编译成功为止,一般不成功的原因肯定都是缺少php的依存套间或者动态连接库,再者是路径指向错误)
 
cp php.ini-dist /usr/local/php/php.ini
 
以下步骤是写入语句到http.conf中,使apache支持PHP程序
cp /usr/local/http/conf/httpd.conf /usr/local/http/conf/httpd.conf.backup

echo AddType application/x-tar .tgz >> /usr/local/http/conf/httpd.conf
 
echo AddType application/x-httpd-php .php >> /usr/local/http/conf/httpd.conf
 
echo AddType image/x-icon .ico >> /usr/local/http/conf/httpd.conf
 
echo DirectoryIndex index.php index.html index.html.var >> /usr/local/http/conf/httpd.conf
 
(测试apache)
 
service httpd stop
 
service httpd start
 
安装好以上三大应用软件之后,下一步开始对mysql数据库进行配置
 
cd /cacti
 
groupadd cacti(新建CACTI组)
 
useradd -g cacti cactiuser(新建隶属于cacti组的cactiuser用户)
 
/usr/local/mysql/mysqld_safe &(启动mysql数据库,使之在后台运行)
 
/usr/local/mysql/bin/mysql(进入mysql数据库)
 
mysql> set password for root@localhost=password('838770');(为mysql中的root用户设置密码为838770
 
mysql> create database cactidb;(创建名为cactidb的数据库)
 
mysql> grant all on cactidb.* to root;(让mysql中的root用户具有对cactidb数据库的操作权限)
 
mysql> grant all on cactidb.* to cactiuser;(让mysql中的cactiuser用户具有对cactidb数据库的操作权限)
 
mysql> set password for cactiuser@localhost=password('838770');(为mysql中的cactiuser用户设置密码为838770
 
mysql> exit(退出mysql数据库)
 
安装RRDTOOL
 
命令格式:
cd /cacti
 
tar -zxvf rrdtool*
 
cd rrdtool*
 
./configure --prefix=/usr/local/rrdtool
 
Make
 
make install
 
安装NET-SNMP
 
cd /cacti
 
tar -zxvf net-snmp*
 
cd net-snmp*
 
./configure-prefix=/usr/local/net-snmp
 
Make
 
make install
 
 
安装CACTI
 
cd /cacti
 
cp cacti* /usr/local/http/htdocs/
 
cd /usr/local/http/htdocs/
 
tar -zxvf cacti*
 
mv cacti-0.8.6b cacti/
 
cd /cacti
 
/usr/local/mysql/bin/mysql --user=root --password=838770 cactidb < cacti.sql(把数据导入数据库)
 
chown -R cactiuser /usr/local/http/htdoc/cacti/rra/
 
chown -R cactiuser /usr/local/http/htdoc/cacti/log/
 
编辑/usr/local/http/conf/htdocs/cacti/include/config.php文件,使之与数据库相连
 
$database_defaut = “cactidb”;
 
$database_hostname = “localhost”;
 
$database_username = “cactiuser”;
 
$database_password = “838770;
 
编辑/etc/ctrontab,加入如下语句,使之定时执行一下命令
 
*/5 * * * * cactiuser /usr/local/php/bin/php
 
/usr/local/http/conf/htdocs/cacti/poller.php > /dev/null 2>&1
 
(注意,不要使用root用户去执行他,让他定时用cactiuser用户去执行,或者手动转换成cactiuser用户去执行,否则会出现图像无法显示的情况)
 
安装完成之后,我们可以在
浏览器中输入
阅读(779) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~