使用Cacti监测系统与网络性能_3

四、Cacti的安装

该安装文档的平台是Linux,其它平台上的安装方法请参照Cacti的官方网站。

运行Cacti需要ApachePHPMySQL的环境,搭建该环境的方法很简单,很多文章有过详细的安装教程,就不在此赘述了。下面是安装Cacti的步骤:

1.设置mysql

创建数据库、数据库用户,调整权限、密码:

# mysql -u root

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 10 to server version: 4.0.23-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>; create database cactidb;

Query OK, 1 row affected (0.00 sec)

mysql>; grant all on cactidb.* to root;

Query OK, 0 rows affected (0.01 sec)

mysql>; grant all on cactidb.* to root@localhost;

Query OK, 0 rows affected (0.01 sec)

mysql>; grant all on cactidb.* to cactiuser;

Query OK, 0 rows affected (0.00 sec)

mysql>; grant all on cactidb.* to cactiuser@localhost;

Query OK, 0 rows affected (0.01 sec)

mysql>; set password for cactiuser@localhost=password('cactipw');

Query OK, 0 rows affected (0.00 sec)

mysql>; exit

2.安装RRDTool

RRDTool官方网站(见文章最后的“资源”)下载最新的RRDTool包,当前最新的版本是rrdtool-1.2.12。在该下载页面上,还可以看到有一个“libs”的目录,里面的包也要全部下载。

那么,我们下载了下面的几个包:

libart_lgpl-2.3.17

libpng-1.2.8-config

zlib-1.2.2

freetype-2.1.9

安装方法:

./configure --prefix=/usr #把东西装到 /usr 目录下

make ; make install #编译及安装

安装完上述lib包后,我们就可以进行RRDTool的安装了:

rrdtool-1.2.12包的安装方法:

cd rrdtool-1.2.12

./configure --prefix=/usr

make && make install

测试:

运行rrdtool –v

可以看到RRDTool的用法以及版本信息:

RRDtool 1.2.12 Copyright 1997-2005 by Tobias Oetiker

Compiled Apr 30 2006 11:30:36

Usage: rrdtool [options] command command_options

Valid commands: create, update, updatev, graph, dump, restore,

last, first, info, fetch, tune, resize, xport

RRDtool is distributed under the Terms of the GNU General

Public License Version 2. (www.gnu.org/copyleft/gpl.html)

For more information read the RRD manpages

RRDTool官方的详细安装方法可以在下载的RRDTool源码里的doc/rrdbuild.pod文件里找到。

3.安装SNMP采集工具

SNMP全名是简单网络管理协议,几乎所有的网络设备(交换机、路由器等)和操作系统默认都安装了snmp服务。

Cacti系统所在的服务器并不一定要安装SNMP服务,但是Cacti系统采集数据要用到Net-SNMP包里面的几个工具,所以最好也在Cacti服务器上安装SNMP服务。我们可以直接在系统中运行snmpwalksnmpget看是否有该命令,如果有则无需安装了。

如果操作系统没有安装SNMP,可以到本文最后的资源里的Net-SNMP官方网站上下载源码或二进制包进行安装。

4.安装Cacti

Cacti是一套PHP程序,当前最新版本是0.8.6h。安装时需要对Cacti包文件和数据库进行部分设置。

假设apacheDocumentRoot目录为/www/htdocs:

cp cacti-0.8.6h.tar.gz /www/htdocs

tar xzvf cacti-0.8.6h.tar.gz

mv cacti-0.8.6h cacti

useradd cactiuser –d /www/htdocs/cacti

导入数据库、设置权限:

cd /www/htdocs/cacti

mysql -u root cactidb < cacti.sql

chown -R cactiuser rra/ log/

编辑配置文件/www/htdocs/cacti/include/config.php

$database_type = “mysql”;

$database_default = “cactidb”;

$database_hostname = “localhost”;

$database_username = “cactiuser”;

$database_password = “cactipw”;

定时让Cactipoller取数据:

crontab –u cactiuser –e

加入:

*/5 * * * * /www/php/bin/php /www/htdocs/cacti/poller.php >; /dev/null 2>;&1

注意:不要使用root用户运行上面的“poller.php”命令,否则请再次运行chown –R cactiuser rra/ log/

1 2 3 4 5


Leave a Reply