Cacti安装配置文档

Cacti安装配置文档

1.安装环境:RedHat AS 5.4

2.安装Apache、MySQL(见apache,mysql安装文档)

安装PHP:

先安装zlib,freetype,libpng,jpeg 以便于让PHP 支持GD 库( Cacti 的WeatherMap插件必须要GD 库的支持)

1).安装zlib

#cd /usr/local/src/tarbag/

#wget http://

#tar zxvf zlib-1.2.3.tar.gz -C ../software/

# cd ../software/zlib-1.2.3/

#./configure --prefix=/usr/local/zlib

#make

#make install

2).安装libpng

# cd /usr/local/src/tarbag/

#wget http://

#tar zxvf libpng-1.2.16.tar.gz -C ../software

# cd ../software/libpng-1.2.16/

#./configure

#make

#make install

注意,这里的makefile 不是用./configure 生成,而是直接从scripts/里拷一个

3)安装freetype

# cd /usr/local/src/tarbag/

#wget http://

#tar zxvf freetype-2.3.4 .tar.gz -C ../software

# cd ../software/freetype-2.3.4/

#./configure --prefix=/usr/local/freetype

#make

#make install

4).安装Jpegtar -zxf jpegsrc-1.v6b.tar.gz

# cd /usr/local/src/tarbag/

#wget http://

#tar zxvf jpegsrc.v6b.tar.gz -C ../software/

# cd ../software/jpeg-6b/mkdir /usr/local/libjpeg

#mkdir -p /usr/local/libjpeg/include

#mkdir /usr/local/libjpeg/bin

#mkdir /usr/local/libjpeg/lib

#mkdir /usr/local/libjpeg/man

#mkdir /usr/local/libjpeg/man/man1//可以用mkdir -p /usr/local/libjpeg/man/man1 一步创建多层目录

#./configure --prefix=/usr/local/libjpeg --enable-shared --enable-static

#make && make install注意,这里configure 一定要带--enable-shared 参数,不然,不会生成共享库需要安装安装libxml 包,但版本太低,PHP5 需要更高版本的libxml 包。

# cd /usr/local/src/tarbag/

#wget http://

#tar –zxvf libxml2-2.6.25.tar.gz -C ../software

# cd ../software/libxml2-2.6.25

# ./configure

# make

# make install

6).安装GD

# cd /usr/local/src/tarbag/

#wget http://

# tar zxvf gd-2.0.33.tar.gz -C ../software/

# cd ../software/gd-2.0.33/

#./configure --prefix=/usr/local/libgd --with-png --with-freetype=/usr/local/freetype --with-jpeg=/usr/local/libjpeg

#make

#make install

编译时显示以下信息:

** Configuration summary for gd 2.0.34:

Support for PNG library: yes

Support for JPEG library: yes

Support for Freetype 2.x library: yes

Support for Fontconfig library: yes

Support for Xpm library: no

Support for pthreads: yes

7).编辑/etc/ld.so.conf,添加以下几行到此文件中。

/usr/local/zlib/lib

/usr/local/freetype/lib

/usr/local/libjpeg/lib

/usr/local/libgd/lib

并执行ldconfig 命令,使用动态装入器装载找到共享库

8).安装PHP

# cd /usr/local/src/tarbag/

#wget http://

#tar -zxvf php-5.2.10.tar.gz -C ../software

#cd ../software/php-5.2.10

#./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-gd=/usr/local/libgd --enable-gd-native-ttf --with-ttf --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/libjpeg --with-png-dir=/usr --with-zlib-dir=/usr/local/zlib --enable-xml --enable-mbstring --enable-sockets --with-libxml-dir=/usr/local

#注:如果出现configure: error: cannot find output from lex; giving up,从光盘安装flex包即可解决。-

# make

# make install

# ln –s /usr/local/php5/bin/* /usr/local/bin/

# vi /usr/local/apache/conf/httpd.conf

AddType application/x-httpd-php .php

修改DirectoryIndex 行,添加index.php修改为

DirectoryIndex index.php index.html index.html.var

# vi /usr/local/apache2/htdocs/index.php

添加以下行:

Phpinfo();

?>

wq 保存退出。

# /usr/local/apache2/bin/apachectl restart在浏览器中输入:http://ip/index.php 进行测试。

对php 编译选项的解释:

--prefix=/usr/local/php //指定PHP 的安装目录

--with-apxs2=/usr/local/apache2/bin/apxs //支持Apache 模块

--with-mysql=/usr/local/mysql //支持MySQl

--with-gd=/usr/local/libgd //支持GD 库

--enable-gd-native-ttf //激活对本地TrueType 字符串函数的支持

--with-ttf //激活对FreeType 1.x 的支持

--with-freetype-dir=/usr/local/freetype //激活对FreeType 2.x 的支持

--with-jpeg-dir=/usr/local/libjpeg //激活对jpeg-6b 的支持

--with-png-dir //激活对png 的支持

--with-zlib-dir=/usr/local/zlib//激活对zlib 的支持

--enable-mbstring //激活mbstring 模块

--with-mail //支持Mail 函数

--enable-xml //支持XML--enable-sockets //支持套接字

3. 安装RRDTool

由于rrdtool-1.2.23 需要一些库文件支持,故需先安装配置支持的环境,然后编译安装。

需要的包:cgilib-0.5.tar.gz、zlib-1.2.3.tar.gz、libpng-1.2.18.tar.gz、freetype-2.3.5.tar.gz、libart_lgpl-2.3.17.tar.gz、rrdtool-1.2.23.tar.gz tar zxf cgilib-0.5.tar.gz

安装zlib

# cd /usr/local/src/software/zlib-1.2.3/

#./configure --prefix=/usr/local/rrdtool/lb

#make

#make install

安装libpng

# cd /usr/local/src/software/libpng-1.2.16/

#./configure --disable-shared --prefix=/usr/local/rrdtool/lb

#make

#make install

安装freetype

# cd /usr/local/src/software/freetype-2.3.4/

#./configure --disable-shared --prefix=/usr/local/rrdtool/lb

#make

#make install

rmdir: /usr/local/rrdtool/lb//include/freetype2/freetype/internal: 没有那个文件或目录

make: [install] 错误 1 (忽略)

Make install 过程会报这个错.直接忽略.

安装libart_lgpl

# cd /usr/local/src/tarbag/

# wget http://

# tar jxvf libart_lgpl-2.3.17.tar.bz2 -C ../software/

# cd ../software/libart_lgpl-2.3.17/

#./configure --disable-shared --prefix=/usr/local/rrdtool/lb

#make

#make install

安装intltool

# cd /usr/local/src/tarbag/

# wget http://

# tar jxvf intltool-0.40.6.tar.bz2 -C ../software/

# cd ../software/intltool-0.40.6/

#./configure

#make

#make install

编译过程会报这个错:checking for XML::Parser... configure: error: XML::Parser perl module is required for intltool

安装perl-XML-Parser

# cd /usr/local/src/tarbag

# wget http://

# tar zxvf XML-Parser-2.34.tar.gz -C ../software/

# cd ../software/XML-Parser-2.34/

# perl Makefile.PL

# make

# make install

安装完XML-Parser再回去重编译intltool

# cd /usr/local/src/software/intltool-0.40.6/

#./configure

# make

# make install

安装rrdtool

# cd /usr/local/src/tarbag

# wget http://

# tar zxvf rrdtool-1.4.3.tar.gz -C ../software/

# cd ../software/rrdtool-1.4.3/

#./configure --prefix=/uar/local/rrdtool --disable-tcl

# make

# make install

4. 安装net-snmp

#cd /usr/local/src/tarbag/

#wget http://

# tar zxvf net-snmp-5.2.4.tar.gz -C ../software

#cd ../software/net-snmp-5.2.4

#./configure --prefix=/usr/local/net-snmp --enable-developer

#make

#make install

# ln –s /usr/local/net-snmp/bin/* /usr/local/bin/

#cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmpd.conf

修改/usr/local/net-snmp/share/snmp/snmpd.conf文件的61和62行,设置可以访问改SNMP的网段以及community名称。

比如设置为

com2sec local localhost public

com2sec mynetwork 192.168.100.0/24 public

# /usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf

启动SNMP 服务

# vi /etc/rc.d/rc.local

//在rc.local 上加入一行

/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf

系统启动时启动SNMP服务。

5. 安装Cacti

Cacti 官方网站:www.cacti.net

#cd /usr/local/src/tarbag

#wget http://

# tar zxvf cacti-0.8.7e.tar.gz

# mv cacti-0.8.7e /usr/loca/apache2/htdocs/cacti

# vi /usr/local/apache2/htdocs/cacti/include/config.php

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cacti";

$database_password = "cacti";

//添加cacti 用户

# useradd cacti

//将rra 目录的所有权给cacti 用户

# chown –R cacti /usr/local/apache/2htdocs/cacti/rra

//修改cacti 目录所属组

# chgrp –R cacti /usr/loca/apache2/htdocs/cacti

//添加cron 任务

*/1 * * * * /usr/local/bin/php /usr/local/apache2/htdocs/cacti/poller.php > /dev/null 2>&1

数据库配置

cp /usr/local/apache2/htdoces/cacti/cacti.sql /tmp/1.sql

mysql> show databases;

mysql> create database cacti;

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| cacti |

| mysql |

| test |

+--------------------+

4 rows in set (0.00 sec)

mysql> use cacti

Database changed

mysql> source /tmp/2.sql

mysql> exit

Bye

#ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so.15.0.0 /usr/lib/libmysqlclient.so.15

#ldconfig这两句要加上,否则系统无法找到libmysqlclient.so.15库(版本不同libmysqlclient.so.的名字也不同)

Chmod 777 /usr/local/apache/htdocs/cacti/log

Chmod 777 /usr/local/apache/htdocs/cacti/rra

8. 完成cacti 的安装

1)在浏览器中输入:http://ip/cacti/

2)默认用户名:admin 密码:admin

这是监控服务器的一部分图:

Cacti安装配置文档_第1张图片

Cacti安装配置文档_第2张图片

Cacti安装配置文档_第3张图片

仅仅初步安装Cacti后,是不支持插件的,要先安装cacti的一个patch--Plugin Architecture!

PA与cacti版本的关系:

PA 1.0 = cacti 0.8.6i

PA 1.1 = cacti 0.8.6i et 0.8.6j

PA 2.0 = cacti 0.8.7b

PA 2.2 = cacti 0.8.7c

PA 2.4 = cacti 0.8.7d

PA 2.5 = cacti 0.8.7e

patch-plugin Arch的安装:

本文是针对cacti 0.8.7e版本的插件安装笔记,所以对应的是PA2.5.

[root@centos53 cacti]# cd /usr/local/src/tarbag/

[root@centos53 src]# wget http://

[root@centos53 src]# unzip cacti-plugin-0.8.7e-PA-v2.5.zip -d cacti-plugin-0.8.7e

[root@centos53 src]# cp -R cacti-plugin-0.8.7e/* /usr/local/apache2/htdocs/cacti

[root@centos53 src]# cd /usr/local/apache2/htdocs/cacti

[root@centos53 cacti]# cp pa.sql /tmp/2.sql

mysql> show databases;

mysql> create database cacti;

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| cacti |

| mysql |

| test |

+--------------------+

4 rows in set (0.00 sec)

mysql> use cacti

Database changed

mysql> source /tmp/2.sql

mysql> exit

[root@centos53 cacti]# patch -p1 -N

如果是通过"http://xxx.xxx.xxx.xxx/cacti/“的URL访问,要修改global.php:

[root@centos53 cacti]# vi /var/www/cacti/include/global.php

/* Default database settings*/

$database_type = "mysql";

$database_default = "cactidb";

$database_hostname = "localhost";

$database_username = "root";

$database_password = "";

$database_port = "3306";

/*

Edit this to point to the default URL of your Cacti install

ex: if your cacti install as at http://serverip/cacti/ this

would be set to /cacti/

*/

$config['url_path'] = '/cacti/';

授权admin用户"plugin Management":

登录后,Utilities--User Management--admin--Realm Permissions,选中“Plugin Management",Save。

NTop的安装以及与Cacti的结合

安装cacti的ntop接口

# cd /usr/local/src/tarbag

# wget http://

# tar zxvf ntop-0.1.tar.gz

# mv ntop-0.1/ /usr/local/apache2/htdocs/cacti/plugins/

# vi /usr/local/apache2/htdocs/cacti/include/global.php //在cacti面板上添加ntop接口

$plugins = array();

$plugins[] = 'ntop';

在cacti面板上打开User Management 选择admin用户,将View NTop勾打上 点击save.

这样在cacti面板top栏就出现了ntop的接口

安装ntop程序

先安装Cgilib

# cd /usr/local/src/tarbag/

# wget http://

# tar zxvf cgilib-0.5.tar.gz -C ../software

# cd ../software/cgilib-0.5/

# make

# cp libcgi.a /usr/lib

# cp cgi.h /usr/include

安装libgd

# cd /usr/local/src/tarbag/

# wget http://

# tar zxvf gd-2.0.33.tar.gz -C ../software/

# cd ../software/gd-2.0.33

# ./configure --prefix=/usr/local/libgd

# make

# make install

安装pcap库

#cd /usr/local/src/tarbag/

#wget http://

#rpm -ivh libpcap-devel-0.9.4-14.el5.i386.rpm

安装Ntop

# cd /usr/local/src/tarbag/

# wget http://

# tar zxvf ntop-3.2.tgz -C ../software/

# cd ../software/ntop-3.2

# ./configure --prefix=/usr/local/ntop --with-gd-root=/usr/local/libgd/ --with-gd-lib=/usr/local/libgd/lib/ --with-gd-include=/usr/local/libgd/include/

# make

# make install

# cp packages/RedHat/ntop.conf.sample /usr/local/ntop/etc/ntop.conf

# useradd ntop

# chown -R ntop:ntop /usr/local/ntop/

NTop配置文件

[root@centos53 /]# vi /usr/local/ntop/etc/ntop.conf

--interface eth0,lo //#eth0 是我的单块网卡 lo是回路

--local-subnets 192.168.10.0/24 //#由于我只是一台机器所以下面的没加,如果您是在路由器或网关上请把对应的ip段改成自己的

--http-server 3000 //运行端口

--db-file-path /usr/local/ntop/var/log //数据库存放路径

--daemon //守护进程方式运行

--user ntop //用户名

--trace-level 3 //默认运行等级

--disable-schedyield //跳过所有错误

NTop第一次启动

第一次运行说明:第一次启动前用下面的命令设置一个管理密码,以后web页面设置的时候用得到。用户名默认admin,密码就是下面的命令设置的。

#/usr/bin/ntop -P -u -A

-P [directory]指定数据库存放路径

-u [user]指定service启动user

-A 设定admin密码,ntop会内建admin管理者帐号于ntop中

如:

# /usr/local/ntop/bin/ntop -P /usr/local/ntop/var/log/ -u ntop -A

Fri Nov 13 14:36:23 2009 NOTE: Interface merge enabled by default

Fri Nov 13 14:36:23 2009 Initializing gdbm databases

ntop startup - waiting for user response!

Please enter the password for the admin user: admin

Please enter the password again: admin

Fri Nov 13 14:37:09 2009 Admin user password has been set

以上操作ntop初始化就完成了。

启动运行

#/usr/local/ntop/bin/ntop -P /usr/local/ntop/var/log/ -u ntop &

或加入启动脚本(若找不到网络设备可用 -i eth0 项指定!)

# echo "/usr/local/ntop/bin/ntop -P /usr/local/ntop/var/log/ -u ntop &" >>/etc/rc.d/rc.local

浏览

http://xxx.xxx.xxx.xxx:3000

你可能感兴趣的:(mysql,centos,database,library,plugins,permissions)