网上找的都是源代码包,装的很是头疼,还好遇到了blogbus的系统工程师,向他请教了下安装cacti的方法。用的是rpm包的方法,才有以下文章。 如果在网上看到有名为 “花开”的写的类似的文章的话,则以他为原创。 因是他现场指导,很是感谢。 再以自身实践过成功后,记下这篇文章,以待以后翻阅,参考用。
#cacti所需软件
PHP 4.3.6+
MySQL 4.1.x or 5.x
RRDTool 1.0.49+ or 1.2.x
NET-SNMP 5.1.2+
PHP 4.3.6+
MySQL 4.1.x or 5.x
RRDTool 1.0.49+ or 1.2.x
NET-SNMP 5.1.2+
#更详细的依赖关系
* httpd
* php
* php-mysql
* php-snmp
* mysql
* mysql-server
* net-snmp
* httpd
* php
* php-mysql
* php-snmp
* mysql
* mysql-server
* net-snmp
#Disable SELinux 关闭SELinux
vi /etc/sysconfig/selinux
vi /etc/sysconfig/selinux
#SELINUX=enforcing
SELINUX=disabled
设置完需要重新启动
SELINUX=disabled
设置完需要重新启动
#下载 Cacti [url]http://www.cacti.net[/url]
wget [url]http://www.cacti.net/downloads/cacti-0.8.7b.tar.gz[/url]
#安装所需的包
yum -y install httpd
yum -y install php
yum -y install php-mysql
yum -y install php-snmp
yum -y install mysql-server
yum -y install perl
yum -y install net-snmp-utils
yum -y install libpng
yum -y install freetype
yum -y install libart_lgpl
yum -y groupinstall Development\ Tools /*这个是开发工具*/
#将httpd和mysqld设置成自动启动
chkconfig httpd on
chkconfig mysqld on
#将httpd和mysqld设置成自动启动
chkconfig httpd on
chkconfig mysqld on
#下载 rrdtool
wget [url]http://dag.wieers.com/rpm/packages/rrdtool/perl-rrdtool-1.2.23-1.el5.rf.i386.rpm[/url]
wget [url]http://dag.wieers.com/rpm/packages/rrdtool/rrdtool-1.2.23-1.el5.rf.i386.rpm[/url]
wget [url]http://dag.wieers.com/rpm/packages/rrdtool/perl-rrdtool-1.2.23-1.el5.rf.i386.rpm[/url]
wget [url]http://dag.wieers.com/rpm/packages/rrdtool/rrdtool-1.2.23-1.el5.rf.i386.rpm[/url]
#安装
rpm -ivh perl-rrdtool-1.2.23-1.el5.rf.i386.rpm rrdtool-1.2.23-1.el5.rf.i386.rpm
rpm -ivh perl-rrdtool-1.2.23-1.el5.rf.i386.rpm rrdtool-1.2.23-1.el5.rf.i386.rpm
#修改mysqld配置
vi /etc/my.cnf
vi /etc/my.cnf
[mysqld]
collation-server = utf8_general_ci
default-collation = utf8_general_ci
character-set-server = utf8
default-character-set = utf8
collation-server = utf8_general_ci
default-collation = utf8_general_ci
character-set-server = utf8
default-character-set = utf8
[mysql]
default-character-set = utf8
default-character-set = utf8
#建立cacti所需数据库,并设置相关权限
mysqladmin create cacti
mysql cacti < cacti.sql ( cacti.sql cacti目录下)
mysql> grant all privileges on cacti.* to
cacti@'localhost';
mysql> grant all privileges on cacti.* to cacti@'127.0.01';
mysql> grant all privileges on cacti.* to cacti@'127.0.01';
mysql> set password for
cacti@'localhost' = password('cactipasswd');
mysql> set password for cacti@'127.0.0.1' = password('cactipasswd');
mysql> set password for cacti@'127.0.0.1' = password('cactipasswd');
#修改cacti配置文件
cp tar -zxvf cacti-0.8.7b.tar.gz /var/www/html
cd cacti-0.8.7b
mv cacti-0.8.7b cacti
tar -zxvf cacti-0.8.7b.tar.gz
cd cacti-0.8.7b
mv cacti-0.8.7b cacti
vi include/config.php ( cacti目录下)
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacitpasswd";
$database_port = "3306";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacitpasswd";
$database_port = "3306";
#为cacti配置apache访问
vi /etc/httpd/conf.d/cacti.conf
Alias /cacti /srv/_webapp/cacti
<Directory /srv/_webapp/cacti >
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory /srv/_webapp/cacti >
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
#设置cacti数据保存目标权限
chown -R apache rra log ( cacti目录下)
chown -R apache rra log ( cacti目录下)
#设置cacti采集
vi /etc/cron.d/cacti
*/5 * * * * apache /usr/bin/php -q /srv/_webapp/cacti/poller.php > /srv/_webapp/cacti/log/poller.log 2>&1
vi /etc/cron.d/cacti
*/5 * * * * apache /usr/bin/php -q /srv/_webapp/cacti/poller.php > /srv/_webapp/cacti/log/poller.log 2>&1
####################
# ARP***监控、处理
####################
# ARP***监控、处理
####################
# 安装 ARPWACTH
yum -y install arpwatch
# 设备成自动启动
chkconfig arpwatch on
# 启动arpwatch服务
serivce arpwatch start 、/etc/init.d/arpwatch start
yum -y install arpwatch
# 设备成自动启动
chkconfig arpwatch on
# 启动arpwatch服务
serivce arpwatch start 、/etc/init.d/arpwatch start
# 设置arpwatch
vi /etc/sysconfig/arpwatch
# -u <username> : defines with what user id arpwatch should run
# -e <email> : the <email> where to send the reports
# -s <from> : the <from>-address
OPTIONS="-u pcap -e [email]caoyuwei@vip.qq.com[/email] -s 'root (Arpwatch)'"
vi /etc/sysconfig/arpwatch
# -u <username> : defines with what user id arpwatch should run
# -e <email> : the <email> where to send the reports
# -s <from> : the <from>-address
OPTIONS="-u pcap -e [email]caoyuwei@vip.qq.com[/email] -s 'root (Arpwatch)'"
# 遍历VLAN内的MAC地址
#!/bin/bash
for i in `seq 254` ; do
arping -c2 210.51.44.$i | awk '/Unicast reply from/{print $4,$5}' | sed 's/\[//' | sed 's/\]//'
done
arping -c2 210.51.44.$i | awk '/Unicast reply from/{print $4,$5}' | sed 's/\[//' | sed 's/\]//'
done
转载于:https://blog.51cto.com/85247/118514