免费注册 查看新帖 |

Chinaunix

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

cacti流量监控服务器搭建手册 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-10-15 18:49 |只看该作者 |倒序浏览
cacti流量监控服务器搭建手册

1、安装环境及软件需求:
centos-5.2  
http://www.centos.org
mysql-5.0.67  
http://www.mysql.com
apache-2.2.9  
http://www.apache.org
php-5.2.6
http://www.php.net
eaccelerator-0.9.5.3
http://eaccelerator.net/
net-snmp-5.4.2
http://www.net-snmp.net
      
rrdtool-1.3.4  
http://oss.oetiker.ch/rrdtool/
cacti-0.87b  
http://www.cacti.net
cacti-spine-0.87a  
http://www.cacti.net
cacti-plugin-arch-2.1
http://cactiusers.org/
php-weathermap-0.95b
http://www.network-weathermap.com/

2、 基本安装:
2.1 centos安装
   具体安装参考其他资料,只选取开发工具包,其他不选。
   安装完后更新源为国内速度比较快的电信服务器
http://mirror.be10.com/centos/
    vi  /etc/yum.repos.d/CentOS-Base.repo
    :1,$s/mirror.centos.org/mirror.be10.com/g
    :wq
   安装插件: yum -y install yum-fastestmirror
   更新系统所有已安装的包:yum update
   后面编译过程需要的一些包也直接yum安装:比如 gd,pango,zlib等
   
2.2 mysql 数据库的安装
   可参考解压出来的目录下 INSTALL-BINARY 文件:
   shell> groupadd mysql
   shell> useradd -g mysql mysql
   shell> tar zxvf mysql.tar.gz
   shell> cd mysql
   shell> ./configure  --prefix=/usr/local/mysql
   shell> make && make install
   shell> cp support-files/my-medium.cnf  /etc/my.cnf
   shell> cd /usr/local/mysql
   shell> chown -R mysql .
   shell> chgrp -R mysql .
   shell> scripts/mysql_install_db --user=mysql
   shell> chown -R root .
   shell> chown -R mysql data
   shell> bin/mysqld_safe --user=mysql &
   
   让mysql开机自动运行:
   法1: echo "/usr/local/mysql/bin/mysqld_safe --user=mysql &" >>/etc/rc.local
   法2: cp support-files/mysql.server /etc/init.d/mysql
      chmod +x /etc/init.d/mysql
      chkconfig --add mysql
      chkconfig --level 35 mysql on
      service mysql start
    或者分别进入rc3.d和rc5.d目录手动建立连接文件:
      cd /etc/rc3.d and rc5.d
      ln -s ../init.d/mysql S86mysql
      ln -s ../init.d/mysql K86mysql
(Note: the number in filename doesn't conflict with other scripts)
   
   把mysql库文件导入系统库路径:
   echo "/usr/local/mysql/lib" >/etc/ld.so.conf.d/mysql.lib.conf
   shell> ldconfig
      
2.3 apache的安装:
   ./configure --prefix=/www --enable-so
   make && make install
   
   编译过程有错的话,就是缺少一些开发库,yum搜索安装即可
   修改配置文件 /www/conf/httpd.conf ,找到User 和Group改为:
     User apache
     Group apache
   在系统中增加帐号: useradd -s /bin/nologin -d /dev/null apache  
   
   开机自动运行: echo "/www/bin/apachectl -k start" >> /etc/rc.local
   
2.4 PHP的安装:
   ./configure --prefix=/www/php \
         --with-apxs2=/www/bin/apxs \
         --with-config-file-path=/www/php \
         --enable-sockets \
         --with-mysql=/usr/local/mysql \
         --with-zlib-dir=/usr/include \
         --with-gd
   make && make install
   cp php.ini-dist /www/php/php.ini
   
   在apache配置文件中增加以下内容来支持php:
   vi /www/conf/httpd.conf
   找到,在DirectoryIndex 后面增加 index.php
   找到,在下面增加以下内容:
      ###############for php and cacti###################
      AddType application/x-tar .tgz
      AddType application/x-httpd-php .php
      AddType image/x-icon .ico
      #######################over########################
   
   库文件处理:
    echo "/www/php/lib" >/etc/ld.so.conf.d/php.lib.conf
    ldconfig
   
2.5  php加速--eaccelerator的安装:
   
    ./configure --prefix=/www/eaccelerator \
           --enable-eaccelerator=shared \
           --with-php-config=/www/php/bin/php-config
    make && make install
   
   编辑PHP配置文件(/www/php/php.ini)增加以下内容:
   
        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     ;  
http://eaccelerator.net
   ;
     ;  2008/10/14 zhyong         ;
     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     
     zend_extension="/www/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
     eaccelerator.shm_size="16"
     eaccelerator.cache_dir="/tmp/eaccelerator"
     eaccelerator.enable="1"
     eaccelerator.optimizer="1"
     eaccelerator.check_mtime="1"
     eaccelerator.debug="0"
     eaccelerator.filter=""
     eaccelerator.shm_max="0"
     eaccelerator.shm_ttl="0"
     eaccelerator.shm_prune_period="0"
     eaccelerator.shm_only="0"
     eaccelerator.compress="1"
     eaccelerator.compress_level="9"
   以上可参考eaccelerator解压后目录内的README文件
   建立eaccelerator的暂存数据目录:
    mkdir /tmp/eaccelerator
    chmod 0777 /tmp/accelerator
   
2.6 rrdtool和net-snmp的安装:

   直接参照解压目录的README和INSTALL文件进行安装
   ./configure
   make && make install
   
   rrdtool库文件:
     echo "/usr/local/rrdtool-1.3.4/lib" >/etc/ld.so.conf.d/rrdtool.lib.conf
     ldconfig
   
2.7 mysql数据库的一些设置:
   
    主要是一些数据库权限的设置
    useradd cactiuser
    /usr/local/mysql/bin/mysql -u root -p
    mysql> set password for
[email=root@localhost=password('cactipw']root@localhost=password('cactipw'[/email]
);     
    mysql> create database cacti;                                   
       mysql> grant all on cacti.* to root;                           
       mysql> grant all on cacti.* to
[email=root@localhost]root@localhost[/email]
;                  
       mysql> grant all on cacti.* to cactiuser;                       
       mysql> grant all on cacti.* to
[email=cactiuser@localhost]cactiuser@localhost[/email]
;            
       mysql> set password for
[email=cactiuser@localhost=password('cactipw']cactiuser@localhost=password('cactipw'[/email]
);
       mysql> flush privileges;               
       mysql> exit   
      
  2.8 cacti的安装:
   
    tar -zxvf cacti-0.8.7b.tar.gz
    mv cacti-0.8.7b /www/htdocs/cacti
    cd /www/htdocs/cacti
    导入cacti数据库
    /usr/local/mysql/bin/mysql -u root -pcactipw cacti

   crontab –u cactiuser –e
   */5 * * * * /www/php/bin/php /www/htdocs/cacti/poller.php > /dev/null 2>&1
   
2.9  cacti-spine 的安装:

   ./configure --with-mysql=/usr/local/mysql/include
   make && make install
   
   默认安装在目录/usr/local/spine
   修改配置文件:  vi /usr/local/spine/etc/spine.conf
        DB_Host         localhost
        DB_Database     cacti   
        DB_User         cactiuser
        DB_Pass         cactipw  
        DB_Port         3306   
     
  2.10 收尾
   
    可执行文件加入路径:
    echo "export PATH=$PATH:/usr/local/mysql/bin:/www/bin:/www/php/bin:/usr/local/rrdtool-1.3.4/bin" >>/etc/profile
    source /etc/profile
   
    启动服务:
     service mysql start  或者 /usr/local/mysql/bin/mysqld_safe --user=mysql &
     /www/bin/apachectl -k start
     
   查看服务是否启动:
       netstat -tunlp |grep :80
       netstat -tunlp |grep :3306
      
   清除防火墙设置: iptables -F   
    现在就可以通过
http://ip/cacti
访问cacti页面啦
    要通过
http://cacti.yourdomain.com
直接访问,需要在DNS服务器上设置域名指向,然后修改apache配置文件
     vi /www/conf/httpd.conf
     修改 DocumentRoot = "/www/htdocs/cacti"
     
     apache错误日志: /www/logs/err_log
     
     初次打开
http://cacti.yourdomain.com
要求设置admin密码,然后是snmpwalk等路径设置
        /usr/local/bin/snmpwalk
        /usr/local/bin/snmpget
        /usr/local/bin/snmpbulkwalk
        /usr/local/bin/snmpgetnext
        /usr/local/rrdtool-1.3.4/bin/rrdtool
        /www/php/bin/php
        /www/htdocs/cacti/log/cacti.log
        /usr/local/spine/bin/spine
      
     进入页面后的基本设置:
     console ->setting ->General
       SNMP Utility Version -->
       RRDTool Utility Version -->
       SNMP Version -->
       SNMP Community -->
      
     console ->setting ->Visual
       Maximum Field Length -->30
      此项与流量图上的提示文字有关,Length太小会造成部分GigabitEthernet1/0/1显示不全
      
    console ->setting ->Poller
      Poller Type --> spine

  2.11 常见问题:
   
    2.11.1 对于Traffic 大于800Mbits/s的无法显示问题.
     在创建graph前修改 Data Templates -> Interface Traffic ->
      1: traffic_in -> Maximum Value Use Per-Data Source Value 默认是100000000 后面再添 几个0就OK了,
      2: traffic_out也要修改,
     最好在使用new graph创建新的graph之前修改,否则之后修改会有一定的麻烦,甚至无法正常工作。
   
   2.11.2 不能连接数据库
     查看以下文件中关于数据库的配置
      /www/htdocs/cacti/include/global.php  config.php
       /usr/local/spine/etc/spine.conf
     查看/tmp/mysql.sock文件是否存在,没有的话重启mysql服务可以自动建立
      service mysql restart
      或 killall -9 mysql ; mysqld_safe --user=mysql &
      
   2.11.3 打开页面遇到"Access Deniess" 或者admin帐号异常
     直接进数据库修改:(默认密码为md5加密)
      mysql -u root -pcactipw
      mysql> use cacti;
      mysql> update user_auth set password=md5('newpasswd') where username='admin';
      mysql> \q
         
   2.11.4 在页面上添加了device,但在Graph下没有图像:
      主要是在crontab计划任务里面是每隔5分钟进行一次poller,所以需要5分钟后才能绘出图像,
      图形位于/www/htdocs/cacti/rra/目录下的 *.rrd文件
      
      也可以手工运行:
      测试被控对象是否开启了SNMP服务,public为团体名:
        snmpwalk -v 2c -c public 10.10.0.1  
      测试PHP是否可以采集到数据
       /www/php/bin/php /www/htdocs/cacti/poller.php

3.插件weathermap的安装
   
  3.1 cacti-plugin-arch 安装
   
   tar -zxvf cacti-plugin-arch.tar.gz
   cd cacti-plugin-arch
   
   直接用处理好的页面替换原来cacti目录下文件:
   cp -rf files-0.8.7b/* /www/htdocs/cacti/
   
   导入数据库:
    mysql -u root -pcactipw cacti  User Management ->admin -> Realm Permissions
   勾选 Plugin -> Weathermap: Configure/Manage
     Plugin -> Weathermap: View
   保存退出。
   
   其他更多插件到
http://cactiusers.org/
               
http://www.cacti.net
  
这就是我目前流量监控服务器的基本搭建过程,更多其他设置参考网络。^_^
         
      
      

      
     
     
  


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/38490/showart_1308205.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP