`
willvvv
  • 浏览: 328501 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

cacti-0.8.7i安装

阅读更多

操作系统:CentOS release 5.7 (Final)
软件包:cacti-0.8.7i.tar.gz,net-snmp-5.7.1.tar.gz,php-5.3.10.tar.gz,mysql-5.1.58-linux-i686-glibc23.tar.gz,httpd-2.2.22.tar.gz

1.安装apache

1.1  cd /usr/local/src
1.2  wget http://labs.renren.com/apache-mirror//httpd/httpd-2.4.1.tar.gz
1.3  tar zvxf httpd-2.2.22.tar.gz
1.4  cd httpd-2.2.22/srclib/apr
1.5  ./configure --prefix=/usr/local/apr
1.6  make && make install
1.7  cd ../apr-util
1.8  ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
1.9  make && make install

1.10 cd /usr/local/src/httpd-2.2.22
1.11 ./configure --prefix=/usr/local/apache --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/bin --enable-mods-shared=all --with-mpm=worker --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache
1.12 make && make install
1.13 vi /usr/local/apache/conf/httpd.conf修改以下参数:

#
    # Listen: Allows you to bind Apache to specific IP addresses and/or
    # ports, instead of the default. See also the <VirtualHost>
    # directive.
    #
    # Change this to Listen on specific IP addresses as shown below to
    # prevent Apache from glomming onto all bound IP addresses.
    #
    #Listen 12.34.56.78:80
    Listen 9999(yourport)

    #
    # ServerName gives the name and port that the server uses to identify itself.
    # This can often be determined automatically, but we recommend you specify
    # it explicitly to prevent problems during startup.
    #
    # If your host doesn't have a registered DNS name, enter its IP address here.
    #
    ServerName 192.168.0.181:9999(yourhost:yourport)
 

1.13 执行 /usr/local/apache/bin/apachectl start,在浏览器输入http://yourip:yourport,如果显示“it works!”说明安装成功。

2.安装snmp

2.1  centos自带有snmp,cacti需要php支持snmp的扩展,本人不知在编译php时如何引用系统的snmp,所以采取手动编译安装snmp的方法
2.2  wget wget http://superb-sea2.dl.sourceforge.net/project/net-snmp/net-snmp/5.7.1/net-snmp-5.7.1.tar.gz
2.3  tar zvxf net-snmp-5.7.1.tar.gz
2.4  cd net-snmp-5.7.1
2.5  ./configure
2.6  make && make install
2.7  修改配置, vi /etc/snmp/snmpd.conf

1、com2sec notConfigUser  default      public
    改为:com2sec notConfigUser (你想监控的那台机器的IP)    public
2、access  notConfigGroup ""      any      noauth    exact  systemview  none  none
    改为:access  notConfigGroup ""      any      noauth    exact  all  none none
3、#view all    included  .1        80
    将前面的 # 注释 去掉。
 

2.8  复制编译安装的snmp的库到系统库:cp /usr/local/lib/libnetsnmp.so.30 /usr/lib,否则会报libnetsnmp.so.30 not found
2.9  service snmpd restart

3.使用yum install 安装rrdtool,zlib,freetype,libpng,jpeg,libxml,gd,等。如yum install zlib。查看系统是否安装zlib的命令rpm -qa|grep zlib,卸载zlib命令rpm -e zlib。

4.安装php

4.1  需要支持mysql, SNMP, XML, Session, Sockets,在 configure时添加对应参数
4.2  wget http://cn2.php.net/distributions/php-5.3.10.tar.gz
4.3  tar zvxf php-5.3.10.tar.gz
4.4  cd php-5.3.10
4.5  ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql  --with-config-file-path=/usr/local/php/etc --with-snmp=/usr/local -enable-xml --enable-sockets

4.6 make & make install

4.7  cp php.ini-production /usr/local/php/etc/php.ini
4.8  修改php时区设置:vi /usr/local/php/etc/php.ini ,否则下面cacti安装之后主页面报global_constants.php等页面的date()函数错误

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Chongqing
 

4.9  apache支持php,vi /usr/local/apache/conf/httpd.conf
    在AddType application/x-gzip .gz .tgz下添加两项:
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
4.10 测试php是否ok,vi /usr/local/apache/htdocs/index.php

<?php
phpinfo();
?>;

 如果显示如下信息说明php安装ok


 
5.  安装cacti(mysql服务已安装)
5.1  wget http://www.cacti.net/downloads/cacti-0.8.7i.tar.gz
     tar zvxf cacti-0.8.7i.tar.gz
5.2  mv cacti-0.8.7i  /usr/local/apache/htdocs/cacti
5.3  cd /usr/local/apache/htdocs/cacti
5.4  groupadd cactiuser
5.5  useradd cactiuser -g cactiuser
5.6  passwd cactiuser
5.6  /usr/local/mysql/bin/mysql -uroot -pyourpass登录mysql命令行,执行以下命令:

create database cacti;
use cacti;
source /usr/local/apache/htdocs/cacti/cacti.sql;   
GRANT ALL PRIVILEGES ON cacti.* TO cactiuser@localhost IDENTIFIED BY "cactipassword";
flush privileges;
 

5.7  修改cacti配置文件,vi include/config.php
    $database_type = "mysql";
    $database_default = "cacti";
    $database_hostname = "localhost";
    $database_username = "cactiuser";
    $database_password = "cactipassword";
    $database_port = "3306";
    $database_ssl = false;     
5.8  修改rra和log文件夹权限:

chown -R cactiuser:cactiuser rra
chown -R cactiuser:cactiuser log

 

5.9  修改计划任务,使CACTI每5分钟获得一次数据
    su cactiuser
    crontab -e
    */5 * * * * /usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php > /dev/null 2>&1

5.10 重启apache,/usr/local/apache/bin/apachectl restart,开始安装cacti


5.11 安装完成之后进入登陆页面,默认用户名admin,密码为空,第一次登陆会要求你设置新密码。


6.在远程主机上配置snmp服务
6.1  yum install net-snmp

       yum install net-snmp-devel

       service snmpd stop
6.2  net-snmp-config --create-snmpv3-user -ro -A cactipassword -a MD5 cactiuser
    提示以下内容:
    adding the following line to /var/net-snmp/snmpd.conf:
    createUser cactiuser MD5 "cactipassword" DES
    adding the following line to /etc/snmp/snmpd.conf:
    rouser cactiuser
6.3  在防火墙里开启snmp的udp端口161
    vi /etc/sysconfig/iptables
    添加:-A RH-Firewall-1-INPUT -p udp -s CactiServerIP --dport 161 -j ACCEPT
    service iptables restart

6.4  分别在远程主机上和cacti主机上检查snmp服务

service snmpd start
snmpwalk -v 3 -u cactiuser -a MD5 -A "cactipassword" -l authNoPriv 127.0.0.1 sysDescr    
snmpwalk -v 3 -u cactiuser -a MD5 -A "cactipassword" -l authNoPriv RemoteIP sysDescr
 

6.5  在cacti添加device


 
    
失败原因排查:
1.检查/usr/local/apache/htdocs/cacti主目录下rra/,有没有数据,如果没有检查rra/ log/的拥有者是不是cactiuser
2.执行 snmpwalk -v 2c -c public 127.0.0.1(serverIP) if    用来测试被控对象()是否开启了SNMP服务,如果不是编译安装snmp可能找不到snmpwalk命令
3.执行 snmpwalk -v 2c 127.0.0.1(serverIP) -c public .1.3.6.1.4.1.2021.10.1.3   查看被控端是否有CPU负载的数据返回
4.执行 /usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php  测试PHP是否可以采集到数据
5.如果可以进去cacti管理页面,但是还是无数据,Console->Configuration->Settings->Paths 检查各项path是否配置ok


  • 大小: 134.9 KB
  • 大小: 105.7 KB
  • 大小: 20.9 KB
  • 大小: 23.8 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics