我是在rhel5上安装的cacti,下面大家看全过程.
1.,准备yum源,我是用的光盘镜像做的本地yum源.
mount /dev/cdrom /media/cdrom (挂在光盘镜像)
vi /etc/yum.repos.d/rhel.repo (编辑yum源)
内容如下:
[Cluster]
name=Red Hat Enterprise Linux
baseurl=file:///media/cdrom/Cluster
enabled=1
gpgcheck=0
[ClusterStorage]
name=Red Hat Enterprise Linux
baseurl=file:///media/cdrom/ClusterStorage
enabled=1
gpgcheck=0
[Server]
name=Red Hat Enterprise Linux
baseurl=file:///media/cdrom/Server
enabled=1
gpgcheck=0
[VT]
name=Red Hat Enterprise Linux
baseurl=file:///media/cdrom/VT
enabled=1
gpgcheck=0
2.通过yum安装http、mysql、php等软件包,并设置为开机自动启动服务.
yum clean all
yum install -y mysql php httpd mysql-server php-mysql
chkconfig mysqld on
chkconfig httpd on
service mysqld start
service httpd start
3.为cacti创建数据库,并为其授权.
mysql -uroot
create database cacti default character set utf8;
grant all on cacti.* to cacti@localhost identified by ''cacti'';
flush privileges;
q (退出)
4.安装net-snmp和rrdtoo软件包
yum -y install net-snmp net-snmp-libs net-snmp-devel net-snmp-perl net-snmp-utils
yum install -y cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel (这步很重要,是为rrdtool安装需要的软件包,这样基本就不会出错了)
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.1.tar.gz
tar zxvf rrdtool-1.3.1.tar.gz
cd rrdtool-1.3.1
./configure --prefix=/usr/local/rrdtool;make;make install
大家注意,安装rrdtool的时候非常容易出错,网上说是版本的问题,换个低版本的就可以了,但我也成功.但是按照我上面安装rrdtool的时候,我是没有出错,大家最好在这的时候要小心.(另外,我会给大家附一个rrdtool安装不成功的解决方案,非常好,请大家到附件去下载)
5.接下来就是安装cacti了.
wget http://www.cacti.net/downloads/cacti-0.8.6c.tar.gz
tar zxvf cacti-0.8.6c.tar.gz
mv cacti-0.8.6c /var/www/cacti
mysql -u root -p cacti < /var/www/cacti/cacti.sql
有密码的输入密码,没密码的直接回车
vi /var/www/cacti/include/config.php
修改以下内容为:
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
(注意格式,千万要小心啊)
useradd cacti -d /var/www/cacti -s /bin/false (添加cacti用户)
这步会出现提示,不要以为是出错了,不信可以执行命令:echo $? ,如果是0的话就是没有出错.
chown -R cacti /var/www/cacti/rra /var/www/cacti/log
6.修改计划任务,使cacti每5分钟获得一次数据.
crontab -e -u cacti
添加如下内容:
*/5 * * * * /usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php > /dev/null 2>&1
7. vi /etc/httpd/conf.d/cacti.conf
内容如下:
Alias /cacti /var/www/cacti
<Directory /var/www/cacti>
DirectoryIndex index.php
AllowOverride all
order deny,allow
deny from all
allow from all
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
</Directory>
|