快速搭建cacti监控系统

2015年9月16日11:11:48 评论 5,802

一. 服务器环境:

OS环境:Centos 6.4_x86_64

WEB环境:nginx 、php、 mysql

二. 准备工作:

1. 下载相关安装包:

# wget http://www.cacti.net/downloads/cacti-0.8.8f.tar.gz

# wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz

# wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8f.tar.gz

# wget http://jaist.dl.sourceforge.net/project/net-snmp/net-snmp/5.4.4/net-snmp-5.4.4.tar.gz

2. 安装相关依赖包:

# yum install cairo-devel libxml2-devel pango-devel

3. 安装net-snmp

# tar zxvf net-snmp-5.4.4.tar.gz && cd net-snmp-5.4.4 && ./configure --prefix=/data/app/net-snmp && make && make install

4. 安装rrdtool

# tar zxvf rrdtool-1.4.7.tar.gz && cd rrdtool-1.4.7 && ./configure --prefix=/data/app/rrdtool && make && make install

5. 创建软链接

# ln -s /data/app/net-snmp/bin/* /usr/local/bin/

# ln -s /data/app/rrdtool/bin/* /usr/local/bin/

三 . 安装cacti

1. 解压cacti,并移动到web目录下

# tar zxvf cacti-0.8.8f.tar.gz

# mv cacti-0.8.8f /opt

2. 建立数据库cacti,并增加对该数据库拥有所有权限的用户名cacti,该用户密码为:cacti

mysql> create database cacti;

mysql> grant all on cacti.* to cacti@localhost identified by 'cacti';

mysql> grant all on cacti.* to cacti@127.0.0.1 identified by 'cacti';

mysql> flush privileges;

3. 导入数据文件

# mysql -ucacti -p cacti </opt/cacti/cacti.sql

4. 修改cacti的配置脚本

# vim /opt/cacti/include/config.php

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cacti";

$database_password = "cacti";

$database_port = "3306";

$database_ssl = false;

5. 初始化cacti

输入URL:http://ip/cacti/install/,进入cacti欢迎安装界面

安装完成后给rra和log两个目录赋予权限

# chmod 777 /data/www/html/cacti/rra

# chmod 777 /data/www/html/cacti/log

6. 添加定时采集任务,没五分钟采集一次

# crontab -e

*/5 * * * * /usr/bin/php /opt/cacti/poller.php

四. FAQ

1. 安装后cacti提示RRDTool 版本不对

原因:在php.ini中存在 disable_functions配置,默认配置中,cli执行函数都是被禁止的,需要在php.ini中将 disable_functions = exec 中的exec去掉,重启服务即可。

weinxin
聂扬帆博客
一个分享IT运维相关工作经验和实战技巧的个人博客

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: