共计 5564 个字符,预计需要花费 14 分钟才能阅读完成。
Cacti 在英文中的意思是仙人掌的意思,Cacti 是一套基于 PHP,MySQL,SNMP 及 RRDTool 开发的网络流量监测图形分析工具。它通过 snmpget 来获取数据,使用 RRDtool 绘画图形,而且你完全可以不需要了解 RRDtool 复杂的参数。它提供了非常强大的数据和用户管理功能,可以指定每一个用户能查看树状结 构、host 以及任何一张图,还可以与 LDAP 结合进行用户验证,同时也能自己增加模板,功能非常强大完善。
基础信息:
OS:RHEL 5.8
SOFT:apr-util-1.4.1.tar.bz2 cmake-2.8.6.tar.gz libmcrypt-2.5.8.tar.gz php-5.4.36.tar.bz2
rrdtool-1.4.7.tar.tar apr-1.4.6.tar.bz2 cacti-0.8.8c.tar.gz httpd-2.4.2.tar.bz2
mysql-5.5.22.tar.gz php-5.4.5.tar.bz2
首先编译安装 LAMP 平台,建议卸载掉对应 rpm 包,否则在各程序协作的时候可能会有问题。
1.install apr and apr-util:
2.tar xf apr-1.4.6.tar.bz2
cd apr-1.4.6
./buildconf
./configure –prefix=/usr/local/apr
make
make install
tar xf apr-util-1.4.1.tar.bz2
cd apr-util-1.4.1
./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr
make
make install
3.install apache:
yum -y install pcre-devel
tar xf httpd-2.4.2.tar.bz2
cd httpd-2.4.2
./configure –prefix=/usr/local/apache –sysconfdir=/etc/httpd –enable-so –enable-suexec –enable-ssl –enable-rewrite –enable-rewrite –with-zlib –with-pcre –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util –enable-modules=most –enable-modules-shared=most –enable-mpms-shared=all
make
make install
echo “PATH=\$PATH:/usr/local/apache/bin” >> /etc/profile
export PATH=$PATH:/usr/local/apache/bin
echo “MANPATH /usr/local/apache/man ” >> /etc/man.config
ln -sv /usr/local/apache/include /usr/include/httpd
4.install cmake:
tar xf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./bootstrap
make
make install
5.install mysql
groupadd -r mysql
useradd -g mysql -r -d /data/mysql mysql
tar xf mysql-5.5.22a.tar.gz
cd mysql-5.5.22a
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLE_PROFILING=1
make
make install
6.cd /usr/local/mysql
chown -R :mysql .
mkdir -pv /data/mysql
chown -R mysql:mysql /data/
cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig –add mysqld
scripts/mysql_install_db –user=mysql –datadir=/data/mysql
sed -i ‘/\[mysqld\]/a \datadir = /data/mysql’ /etc/my.cnf
sed -i ‘s/thread_concurrency = 8/thread_concurrency = 2/g’ /etc/my.cnf
echo “PATH=$PATH:/usr/local/mysql/bin” >> /etc/profile
export PATH=$PATH:/usr/local/mysql/bin
echo “MATHPATH /usr/local/mysql/man” >> /etc/man.config
ln -sv /usr/local/mysql/include /usr/include/mysql
echo ” /usr/local/mysql/lib ” >> /etc/ld.so.conf.d/mysql.conf
ldconfig
service mysqld start
6.install php
安装 php 之前有可能会要求安装 libmcrypt,我直接在 chinaunix 下载的源码 编译安装即可,然后编译 PHP 时加上 –with-mcrypt=DIR
tar xf php-5.4.4.tar.bz2
cd php-5.4.4
./configure –prefix=/usr/local/php –with-mysql=/usr/local/mysql –with-openssl –with-mysqli=/usr/local/mysql/bin/mysql_config –enable-mbstring –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –with-apxs2=/usr/local/apache/bin/apxs –with-mcrypt –with-config-file-path=/etc –with-config-file-scan-dir=/etc/php.d –with-bz2 –enable-sockets
make
make install
cp php-5.4.4/php.ini-production /etc/php.ini
echo “AddType application/x-httpd-php .php ” >> /etc/httpd/httpd.conf
echo “AddType application/x-httpd-php-source .phps” >> /etc/httpd/httpd.conf
sed -i ‘s/DirectoryIndex index.html/DirectoryIndex index.php index.html/g’ /etc/httpd/httpd.conf
上面所有操作无错误执行完以后可以建个测试 php 页测试下是不是 OK,如果没问题,开始装 cacti 部分:
1. 我为 cacti 直接建立的虚拟主机:
首先修改 httpd.conf 添加:include /etc/httpd/extra/httpd-vhosts.conf
然后修改 http-vhosts.conf:
<VirtualHost *:80>
DocumentRoot “/usr/local/apache/htdocs/cacti
ServerName cacti.linuxidc.com
ErrorLog “logs/cacti-error_log”
CustomLog “logs/cacti-access_log” common
</VirtualHost>
2. 安装 rrdtool:
tar xf rrdtool-1.4.7.tar.gz
cd rrdtool-1.4.7
./configure –prefix=/usr/local/rrdtool
make
make install
echo “MANPATH /usr/local/rrdtool/share/man” >> /etc/man.config
echo “PATH=$PATH:/usr/local/rrdtool/bin ” >> /etc/profile
export PATH=$PATH:/usr/local/rrdtool/bin
ln -sv /usr/local/rrdtool/include /usr/include/rrdtool
echo “/usr/local/rrdtool/lib” >> /etc/ld.so.conf.d/rrdtool.conf
ldconfig
3.yum 安装 net-snmp、net-snmp-util 并设置自动运行,此处不给详细命令了
4. 安装 cacti
为 cacti 创建数据库,并初始化所需要表:
1.mysqladmin create cacti // 此时的密码为 mysql 的密码
2.cd /usr/local/apache/htdocs/cacti
3.mysql cacti < cacti.sql
创建 mysql 用户,使用 cacti 能访问其 cacti 数据库
mysql -e “GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY ‘cactiuser'”;
1.// 创建了用户 cactiuser 密码也为 cactiuser
2.mysqladmin -p flush-privileges
3.mysql -ucactiuser -p // 验证一下是否正确
接着创建系统用户 cactiuser,以之运行 cacti 的数据获取和日志记录等工作
1.useradd cactiuser
2.chown -R cactiuser:cactiuser /usr/local/apache/htdocs/cacti/{log,rra}
以 cactiuser 用户的身份,每 5 钟获取一次数据:
1.echo ‘*/5 * * * * /usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php &> /dev/null’ > /var/spool/cron/cactiuser
修改 php 时区:
1.vim /etc/php.ini
2.date.timezone = Asia/Shanghai
编辑 cacti 的配置文件 include/config.php 启用并修改如下行:
//$url_path = “/cacti/”;
我们这里将之修改为:
$url_path = “/”;
而后在浏览器中打开 http://cacti.linuxidc.com,按提示一步步配置即可完成安装。
密码第一次输入的时候,会让修改密码,用户默认为 admin 密码为 admin
————————————– 分割线 ————————————–
RHEL6.4 中使用 Cacti+Spine 监控主机实现发送邮件报警 http://www.linuxidc.com/Linux/2013-11/92795.htm
RHEL6.4 中使用 Cacti+Spine 监控远程主机 http://www.linuxidc.com/Linux/2013-11/92796.htm
CentOS 5.5 完整安装 Cacti+Spine http://www.linuxidc.com/Linux/2011-12/49701.htm
CentOS 6 下 Cacti 搭建文档 http://www.linuxidc.com/Linux/2013-06/86595.htm
RHEL5.9 下 Cacti 监控部署详解 http://www.linuxidc.com/Linux/2013-06/85427.htm
CentOS 6.3 下 Cacti 安装详解 http://www.linuxidc.com/Linux/2013-05/84279.htm
CentOS Linux 下快速安装配置 Cacti 中文版 http://www.linuxidc.com/Linux/2013-03/81627.htm
————————————– 分割线 ————————————–
Cacti 的详细介绍 :请点这里
Cacti 的下载地址 :请点这里