rhel5 下cacti安装日志

1)安装rrdtool
 
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.0.x/rrdtool-1.0.50.tar.gz
tar xzvf rrdtool-1.0.50.tar.tar  
cd rrdtool-1.0.50
./configure
make && make install
 
 

2)安装php组件  
wget http://autoinstall.plesk.com/PSA_8.2.0/update-rpm-RedHat-el5-i386/php-mysql-5.1.6-5.el5.i386.rpm
wget  http://autoinstall.plesk.com/PSA_8.2.0/update-rpm-RedHat-el5-i386/php-pdo-5.1.6-5.el5.i386.rpm
rpm -ivh php-pdo-5.1.6-5.el5.i386.rpm  
rpm -ivh php-mysql-5.1.6-5.el5.i386.rpm  
 
wget http://ftp.riken.jp/Linux/scientific/5x/archive/obsolete/php-snmp-5.1.6-5.el5.i386.rpm
rpm -ivh php-mysql-5.1.6-5.el5.i386.rpm   

3)安装cacti
wget http://www.cacti.net/downloads/cacti-0.8.7b.tar.gz
tar xzvf cacti-0.8.7b.tar.gz  
cd cacti-0.8.7b
mysqladmin --user=root create cacti
mysql -u root  cacti < cacti.sql
mysql -u root  mysql
mysql >grant all on cacti.* to 'cacti-user'@'localhost' identified by '123';
mysql >flush privileges;
 
Edit include/config.php and specify the database type, name, host, user and password for your Cacti configuration.
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti-user";
$database_password = "123";
 
 
useradd cactiuser
chown -R cactiuser rra/ log/

mkdir /var/www/html/cacti
cp -r cacti-0.8.7b/* /var/www/html/cacti

 
crontab -u cactiuser -e
*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1


4)访问页面 4.1)访问http://ip/cacti
发现:
FATAL: Cannot connect to MySQL server on 'localhost'. Please make sure you have specified a valid MySQL database name in 'include/config.php'

于是将mysql 的sock从/tmp/mysql.sock改为/var/lib/mysql/mysql.sock


4.2)再次访问发现:
Oct 23 16:25:44 yxdx7 setroubleshoot:      SELinux is preventing the /usr/sbin/httpd from using potentially mislabeled files .index (usr_t).      For complete SELinux messages. run sealert -l 3d83917a-fc67-4736-b26e-09a9072848a4

于是禁掉selinux

4.3)再次访问
终于可以访问了

但是一个图也看不到
ERROR: opening '/var/www/html/cacti/rra/localhost_mem_buffers_3.rrd': No such file or directory

直接运行 php /var/www/html/cacti/poller.php
发现:
ERROR: creating '/var/www/html/cacti/rra/localhost_mem_buffers_3.rrd': Permission denied
10/25/2008 11:30:17 AM - SYSTEM STATS: Time:1.1565 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:5 RRDsProcessed:5
估计是我重新解压cacti目录后忘了chown了
于是
chown -R cactiuser /var/www/html/cacti/log /var/www/html/cacti/rra

4.4)
ok,至少本地几个默认的图出来了

发现有图,但是无数据,都是nan,此时的模板还是Linux - Memory Usage ,检测的是本机

直接运行 php /var/www/html/cacti/poller.php
出现:
10/25/2008 12:39:24 PM - POLLER: Poller[0] WARNING: Cron is out of sync with the Poller Interval!  The Poller Interval is '300' seconds, with a maximum of a '300' second Cron, but 1198 seconds have passed since the last poll!
于是:*/5 * * * *  cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1
改为 */5 * * * *  php /var/www/html/cacti/poller.php > /dev/null 2>&1
ok了

4.5)
然后使用模板ucd/net - Memory Usage,检测局域网内别的机器
发现有图,但是无数据,都是nan,
cacti log有如下错误
10/27/2008 08:55:03 AM - CMDPHP: Poller[0] Host[4] DS[30] WARNING: Result from SNMP not valid.  Partial Result:  
10/27/2008 08:55:05 AM - CMDPHP: Poller[0] Host[4] DS[32] WARNING: Result from SNMP not valid.  Partial Result:  
10/27/2008 08:55:07 AM - CMDPHP: Poller[0] Host[4] DS[31] WARNING: Result from SNMP not valid.  Partial Result:  
10/27/2008 08:55:09 AM - CMDPHP: Poller[0] Host[4] DS[28] WARNING: Result from SNMP not valid.  Partial Result:  
10/27/2008 08:55:11 AM - CMDPHP: Poller[0] Host[4] DS[29] WARNING: Result from SNMP not valid.  Partial Result:  
10/27/2008 08:55:13 AM - CMDPHP: Poller[0] Host[4] DS[27] WARNING: Result from SNMP not valid.  Partial Result:  
10/27/2008 08:55:15 AM - CMDPHP: Poller[0] Host[4] DS[25] WARNING: Result from SNMP not valid.  Partial Result:  
10/27/2008 08:55:17 AM - CMDPHP: Poller[0] Host[4] DS[26] WARNING: Result from SNMP not valid.  Partial Result:  
10/27/2008 08:55:19 AM - CMDPHP: Poller[0] Host[4] DS[24] WARNING: Result from SNMP not valid.  Partial Result:  
10/27/2008 08:55:20 AM - SYSTEM STATS: Time:19.1584 Method:cmd.php Processes:1 Threads:N/A Hosts:3 HostsPerProcess:3 DataSources:14 RRDsProcessed:14

于是
wget ftp://mirror.switch.ch/pool/1/mirror/scientificlinux/5rolling/i386/SL/net-snmp-utils-5.3.1-24.el5_2.1.i386.rpm
安装获得snmpget snmpwalk snmpbulkwakl snmpgetnext

 
snmpwalk -v 2c -c public your_remote_ip if
错误:
Timeout: No Response from your_remote_ip
 
于是修改snmpd配置 并启动snmpd
com2sec notConfigUser  default  public--->com2sec notConfigUser  your_snmpd_server_ip public
#view all    included  .1  80---->view all    included  .1  80

 
snmpwalk -v 2c -c public your_remote_ip system ok

snmpwalk -v 2c -c public your_remote_ip if
错误:
IF-MIB::ifTable = No Such Object available on this agent at this OID

于是再次修改snmpd.conf,并重启snmpd
access  notConfigGroup ""      any       noauth    exact  systemview none none-->
access  notConfigGroup ""      any       noauth    exact  all    none none

再次snmpwalk -v 2c -c public your_remote_ip if
ok

再访问页面终于图和数据出来了


整个安装过程遇到很多问题,基本都已解决,总结如下
1)mysql的安装问题导致页面无法访问通常是mysql非标准安装引起的,如果把mysql.sock配到/var/lib/mysql/mysql.sock应该可以解决
2)图出不来多数是cron的问题或者权限问题,可以直接执行脚本看看log
3)图出来但是页面数据nan通常是snmp配置的问题,可通过snmpwalk检测,修改snmpd.conf应该可以搞定


 
 
 

你可能感兴趣的:(linux)