免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5927 | 回复: 2
打印 上一主题 下一主题

企业cacti 详细配置 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-08-15 00:51 |只看该作者 |倒序浏览


文件:
cacti

[
编辑本段
]关于Cacti  Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具。它通过snmpget来获取数据,使用RRDtool绘画图形,而且你完全可以不需要了解RRDtool复杂的参数。它提供了非常强大的数据和用户管理功能,可以指定每一个用户能查看树状结构、host以及任何一张图,还可以与LDAP结合进行用户验证,同时也能自己增加模板,功能非常强大完善,界面友好。
  虽然 MRTG 是一套非常好用的软件但是它毕竟是一套很旧的软件了,其作者在多年前已经开发出 RRDTool 代替该软件,现在已经发展的很成熟了,但由于 RRDTool 的指令非常复杂,对于使用者非常的麻烦,幸运的是有一套软件 Cacti 的发展就是基于让 RRDTool 使用者更方便使用该软件,除了基本的 Snmp 流量跟系统资讯监控外,Cacti 也可外挂 Scripts 及加上 Templates 来作出各式各样的监控图
  Cacti中文站点&社区
  http://www.cacti.com.cn/ 中文站点
  http://www.cacti.com.cn/newbbs/ 中文社区
  相关下载:
  CactiEZ中文版V9,基于RHEL5.2,支持更多的硬盘和阵列卡,系统更稳定,支持中文页面和中文图形,美化字体。
  使用说明:
  root密码: CactiEZ
  登录系统后,请尽快修改root密码。
  Cacti登录用户名: admin
  Cacti登录密码: admin
  第一次登录Cacti需要修改密码。
  下载地址:
  http://122.225.31.253/CactiEZ_V9.1.iso
  MD5: 65656f9e784e10640026a43bd1be00f7




安装Apache、MySQL、PHP
(1).安装MySQL
下载地址:http://dev.mysql.com/downloads/mysql/5.0.html
//查看系统中是否已经安装了MySQL,如果是卸载所有以mysql开头的包。
# rpm –qa | grep mysql
# rpm –e mysql-*
//查找/etc/my.cnf(MySQL的选项配置文件),如果有请删除它,以免影响新安装版本的启动。
# rm –f /etc/my.cnf
# tar –zxvf mysql-standard-5.0.27-linux-i686-glibc23.tar.gz
# cp –rf mysql-standard-5.0.27-linux-i686-glibc23 /usr/local/
//建立符号链接,如果以后有新版本的MySQL的话,你可以仅仅将源码解压到新的路径,然后重新做一个符号链接就可以了。这样非常方便,数据也更加安全。
# ln –s mysql-standard-5.0.27-linux-i686-glibc23 /usr/local/mysql
//添加用于启动MySQL的用户及用户组(如果以前安装过MySQl,用户及用户组可能已存在)。
# useradd mysql
# groupadd mysql
//初始化授权表
# cd /usr/local/mysql
# scripts/mysql_install_db
//修改MySQl目录的所有权
# cd /usr/local
# chgrp –R mysql mysql-standard-5.0.27-linux-i686-glibc23
# chgrp –R mysql mysql
# chown –R mysql mysql-standard-5.0.27-linux-i686-glibc23/data
# chown –R mysql mysql/data
# ln –s /usr/local/mysql/bin/* /usr/local/bin/
//启动Mysql
# bin/safe_mysqld --user=mysql &
//配置系统启动时自动启动MySQl
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
//修改MySQL的最大连接数
# vi /etc/my.cnf
//添加以下行
[mysqld]
set-variable=max_connections=1000
set-variable=max_user_connections=500
set-variable=wait_timeout=200
//max_connections设置最大连接数为1000
//max_user_connections设置每用户最大连接数为500
//wait_timeout表示200秒后将关闭空闲(IDLE)的连接,但是对正在工作的连接不影响。
//保存退出,并重新启动MySQL
//重新启动MySQL后使用下面的命令查看修改是否成功
# mysqladmin -uroot -p variables
Password:
//可以看到以下项说明修改成功
| max_connections                 | 1000
| max_user_connections            | 500
| wait_timeout                    | 200

(2).安装Apache
下载地址:http://httpd.apache.org/
# tar –zxvf
httpd-2.2.4.tar.gz
# cd httpd-2.2.4
# ./configure --prefix=/usr/local/apache --enable-so
//编译时加上加载模块参数--enable-so
# make
# make install
#vi /usr/local/apache/conf/httpd.conf
  //修改Apache配置文件,添加ServerName
www.yourdomain.com
              (或ServerName 本机ip)
# vi /etc/rc.d/rc.local
  //在rc.local上加入一行/usr/local/apache/bin/apachectl –k start,系统启动时启动Apache服务。
(3).安装PHP
先安装zlib,freetype,libpng,jpeg以便于让PHP支持GD库(Cacti的WeatherMap插件必须要较新GD库的支持)
库文件下载地址:http://oss.oetiker.ch/rrdtool/pub/libs/
1).安装zlib
  tar zlib-1.2.3.tar.gz
  cd zlib-1.2.3
  ./configure --prefix=/usr/local/zlib
  make
  make install
2).安装libpng
  tar zxvf libpng-1.2.16.tar.tar
  cd libpng-1.2.16
  cd scripts/
  mv makefile.linux ../makefile
  cd ..
  make
  make install
  注意,这里的makefile不是用./configure生成,而是直接从scripts/里拷一个
3).安装freetype
  tar zxvf freetype-2.3.4 .tar.gz
  cd freetype-2.3.4  
  ./configure --prefix=/usr/local/freetype
  make
  make install
4).安装Jpeg
   tar -zxf jpegsrc-1.v6b.tar.gz
   cd jpeg-6b/
   mkdir /usr/local/libjpeg
   mkdir /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 一步创建多层目录
   ./configure --prefix=/usr/local/libjpeg --enable-shared --enable-static
   make && make install
注意,这里configure一定要带--enable-shared参数,不然,不会生成共享库

5).安装Fontconfig
tar -zxvf fontconfig-2.4.2.tar.gz
cd fontconfig-2.4.2
./configure --with-freetype-config=/usr/local/freetype
make
make install
6).安装GD
  tar -zxvf gd-2.0.34.tar.gz
  cd gd-2.0.34
  ./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
    并执行ldconfig命令,使用动态装入器装载找到共享库

8).安装libxml,RedHat AS 4默认安装libxml包,但版本太低,PHP5需要更高版本的libxml包。
      # tar –zxvf libxml2-2.6.25.tar.gz
      # cd libxml2-2.6.25
      # ./configure
      # make
      # make install

9).安装PHP
PHP下载地址:http://www.php.net/downloads.php#v5
tar -zxvf  php-5.2.3.tar.gz
cd php-5.2.3
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-gd=/usr/local/libgd --enable-gd-native-ttf --with-ttf --enable-gd-jis-conv --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
# make
# make install
# cp php.ini-recommended /usr/local/php/lib/php.ini
# ln –s /usr/local/php/bin/* /usr/local/bin/
# vi /usr/local/apache/conf/httpd.conf
查找AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
在其下加入 AddType application/x-tar .tgz
AddType application/x-httpd-php .php
AddType image/x-icon .ico
修改DirectoryIndex 行,添加index.php
修改为DirectoryIndex index.php index.html index.html.var
# vi /usr/local/apache/htdocs/test.php
添加以下行:
//php标记(用代替[)
[?php      
Phpinfo();
?]
wq保存退出。
# /usr/local/apache/bin/apachectl –k stop
#/usr/local/apache/bin/apachectl –k start
在浏览器中输入:
http://www.yourdomain.com
/test.php进行测试。

对php编译选项的解释:
--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 字符串函数的支持
--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=/usr   //激活对 png 的支持
--with-zlib-dir=/usr/local/zlib //激活对zlib 的支持
--enable-mbstring    //激活mbstring模块
--enable-gd-jis-conv //使JIS-mapped可用,支持日文字体
--with-mail   //支持Mail函数
--enable-xml     //支持XML
--enable-sockets      //支持套接字
     
1.安装RRDTool
由于rrdtool-1.2.6.tar.gz需要一些库文件支持,故需先安装配置支持的环境,然后编译安装。
./configure
Make  make install
直接运行以下bash脚本就可以完成安装:
注意:将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放到/root/rrdtool-1.2.23目录下,将脚本保存为/root/rrdtool-1.2.23/rrdtoolinstall.sh,并给执行权限chmod u+x /root/rrdtool-1.2.23/rrdtoolinstall.sh。
以下链接是我重新打好的一个rrdtool-1.2.23的安装包,里面包括了所有用到的库文件和安装脚本,下载解压后执行脚本rrdinstall.sh即可以完成RRDTool的安装。
点击下载
rrdtool-1.2.23.tar.gz
  可以不用移动
如果以上脚本安装失败,可以试试以下安装包:
http://61.156.20.41/autodownload/rrdtool-1.2.11.tar.gz
#!/bin/sh
BUILD_DIR=`pwd`
INSTALL_DIR=/usr/local/rrdtool
cd $BUILD_DIR
tar zxf cgilib-0.5.tar.gz
cd cgilib-0.5
make CC=gcc CFLAGS="-O3 -fPIC -I."
mkdir -p $BUILD_DIR/lb/include
cp *.h $BUILD_DIR/lb/include
mkdir -p $BUILD_DIR/lb/lib
cp libcgi* $BUILD_DIR/lb/lib
cd $BUILD_DIR
tar  zxf zlib-1.2.3.tar.gz
cd zlib-1.2.3
env CFLAGS="-O3 -fPIC" ./configure --prefix=$BUILD_DIR/lb
make
make install
cd $BUILD_DIR
tar zxvf libpng-1.2.18.tar.gz
cd libpng-1.2.18
env CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS="-O3 -fPIC" \
    ./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install
cd $BUILD_DIR
tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.2.5
env CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS="-O3 -fPIC" \
    ./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install
cd $BUILD_DIR
tar zxvf libart_lgpl-2.3.17.tar.gz
cd libart_lgpl-2.3.17
env CFLAGS="-O3 -fPIC" ./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install
IR=-I$BUILD_DIR/lb/include
CPPFLAGS="$IR $IR/libart-2.0 $IR/freetype2 $IR/libpng"
LDFLAGS="-L$BUILD_DIR/lb/lib"
CFLAGS=-O3
export CPPFLAGS LDFLAGS CFLAGS
cd $BUILD_DIR
tar zxf rrdtool-1.2.23.tar.gz
cd rrdtool-1.2.23
./configure --prefix=$INSTALL_DIR --disable-python --disable-tcl && make && make install
//完成后建立符号连接
ln –s /usr/local/rrdtool/bin/* /usr/local/bin/
//执行rrdtool看是否安装正确
2.安装net-snmp
RedHat默认安装了SNMP服务,但好象没有snmpwalk,snmpget这两个命令,所以需要编译安装NET-SNMP。
NET-SNMP官方网站:
http://www.net-snmp.org/
# tar zxvf net-snmp-5.2.4.tar.gz
#cd 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
//修改snmpd.conf(修改COMMUNITY、允许抓取snmp数据的主机、抓取数据范围等)。
# /usr/local/net-snmp/sbin/snmpd     //启动SNMP服务
# vi /etc/rc.d/rc.local
   //在rc.local上加入一行/usr/local/net-snmp/sbin/snmpd,系统启动时启动SNMP服务。

3.安装Cacti
Cacti官方网站:
www.cacti.net/
# tar –zxvf cacti-0.8.6j.tar.gz
# mv –r cacti-0.8.6j /usr/loca/apache/htdocs/cacti
# vi /usr/local/apache/htdocs/cacti/include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";

//添加cacti用户
# useradd cacti
//将rra目录的所有权给cacti用户
# chown –R cacti /usr/loca/apache/htdocs/cacti/rra
//修改cacti目录所属组
# chgrp –R cacti /usr/loca/apache/htdocs/cacti
//为cacti用户添加cron任务
# su – cacti
# crontab –e
*/5 * * * * /usr/local/bin/php /usr/local/apache/htdocs/cacti/poller.php > /dev/null 2>&1
注意:首次执行poller.php时请使用cacti用户,否则生成的rrd文件cacti将没有写入权限。
     
4.安装Cactid
CACTID 的安装需要以下支持:
o    net-snmp-devel (需要编译安装net-snmp时添加--enable-developer选项)
o    mysql               
o    mysql-devel     (mysql源文件编译安装后默认支持)
o    openssl-devel  (Redhat默认安装)
# tar -zxvf cacti-cactid-0.8.6i.tar.gz
# cd cacti-cactid-0.8.6i
# ./configure --with-mysql=/usr/local/mysql --with-snmp=/usr/local/net-snmp
# make
//这时你将在此目录下看到多出了cactid、cactid.conf两个文件
# mkdir /usr/local/cactid
# cp cactid cactid.conf /usr/local/cactid
# vi  /usr/local/cactid/cactid.conf       //修改cactid配置文件
DB_Host         127.0.0.1
DB_Database     cacti
DB_User         cacti
DB_Pass         cacti
     
5.数据库配置
#mysql –uroot –p
Password:
mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)

mysql> grant all on cacti.* to cacti@localhost identified by “cacti”;
Query OK, 1 row affected (0.00 sec)

mysql>exit
# cd /usr/local/apache/htdocs/cacti
# mysql –uroot –p cacti
Password:
     
3工程验收:
.完成cacti的安装
1).在浏览器中输入:
http://www.yourdomain.com/cacti/
默认用户名:admin 密码:admin
2).更改密码
3).设置cacti用到的命令路径
snmpwalk Binary Path          /usr/local/ bin/snmpwalk
snmpget Binary Path         /usr/local/ bin/snmpget
RRDTool Binary Path         /usr/local/ bin/rrdtool
PHP Binary Path              /usr/local/bin/php
Cacti Log File Path           /usr/local/apache/htdocs/cacti/log/cacti.log
Cactid Poller File Path      /usr/local/cactid/cactid
file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/ksohtml/wps_clip_image-10904.png
4).进入cacti后需确认更改以下位置:(如下图)
Console>
Settings
>General
file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/ksohtml/wps_clip_image-11288.png

Console>
Settings
>Poller
file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/ksohtml/wps_clip_image-11647.png


排错:
mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
使用网上介绍的方法修改root用户的密码:
# mysqladmin -uroot -p password 'newpassword'
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
解决:
方法一:
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: 输入新设的密码newpassword>
mysql>
方法二:
直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:
# mysql -udebian-sys-maint -p
Enter password: 输入[client]节的密码>
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';2009-8-6
mysql> FLUSH PRIVILEGES;
mysql> quit
# mysql -uroot -p
Enter password: 输入新设的密码newpassword>
mysql>
排错:图片不能显示
     解决:这个原因是因为没有在服务器中执行下面的命令
/usr/local/php/bin/php /usr/local/apach2/htdocs/cacti/poller.php
个人总结cacti有图无数据解决办法
1,查看log下的日志文件。一般那里会有提示
2,测试SNMP是不是工作正常 snmpwalk -c community -v 2c hostIP if正常的话会出现一些数据。不正常会出现一些错误,也会有对应的错误提示。
3,自动运行poller.php没有。有没有加入cacti的的用户。。有没有给cacti用户写入rra/ log/的权限。对应的命令为:pw useradd cactiuser –d /www/htdocs/cacti(具体路径具体对待)命令作用。为cactiuser这个用户加上cacti这个文件夹的权限  cd /www/htdocs/cacti    chown -R cactiuser rra/ log/  cactiuser加到/rra /log的写权限。
4,crontab –u cactiuser –e  为cactiuser加上自动运行poller.php的任务:
*/1     *       *       *       *       root    /usr/local/bin/php /usr/local/share/cacti/poller.php /dev/null 2>&1
1分钟刷新一次数据。你也可以根据需要还设置。
5。把cacti目录里的cmd.php和poller.php文件加下运行的权限。
For linux
[root@script opt]# vi /etc/snmp/snmpd.conf
       更改 com2sec notConfigUser  default       public
       改为 com2sec notConfigUser  127.0.0.1     public #注 127.0.0.1 是安装cacti服务机IP,指定只有这IP才能获取本机的SNMP信息 提高安全性
       更改 access  notConfigGroup ""      any       noauth    exact  systemview  none
none
       改为 access  notConfigGroup ""      any       noauth    exact  all         none
none
       将 #view all    included  .1         80 前面的 # 注释去掉
保存退出 :wq
[root@script opt]# service snmpd restart
注:如果你机器内没有snmpwalk和snmpge命令,请到安装盘里查找 net-snmp-utils 包,执行 rpm -
ivh net-snmp-utils-5.0.9-2.30E.15.i386.rpm 之后这两个命令就在系统里了。其他包也都在安装盘
里 确保安装这四
.rar
大小:
1878KB
下载:
下载

文件:
awk.pdf
大小:
881KB
下载:
下载


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/103362/showart_2027780.html

论坛徽章:
0
2 [报告]
发表于 2009-12-13 11:19 |只看该作者
Warning: mysql_connect() [function.mysql-connect]: Access denied for user: 'cactiuser@localhost' (Using password: YES) in /usr/local/apache/htdocs/cacti/lib/adodb/drivers/adodb-mysql.inc.php on line 324

Cannot connect to MySQL server on 'localhost'. Please make sure you have specified a valid MySQL database name in 'include/config.php'.
楼主,打开浏览器后,这个错误是什么情况呀


还有就是图片老是显示小x号是怎么回事呀

[ 本帖最后由 laowu2517 于 2009-12-13 17:59 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2010-03-15 13:50 |只看该作者
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP