一. cacti 架构 二. cacti工作流程 三. cacti的安装 1. 安装环境:RedHat AS4.8 2. 安装Apache、MySQL、PHP (1).安装MySQL //查看系统中是否已经安装了MySQL,如果是卸载所有以mysql 开头的包。 # rpm –qa | grep mysql # rpm –e mysql-* //查找/etc/my.cnf(MySQL 的选项配置文件),如果有请删除它,以免影响新 安装版本的启动。 # rm –f /etc/my.cnf # tar –zxvf mysql-4.1.10.tar.gz # ./configure --prefix=/usr/local/mysql && make && make install //添加用于启动MySQL 的用户及用户组(如果以前安装过MySQl,用户及用户 组可能已存在)。 # useradd mysql # cd /usr/local/mysql //修改MySQl 目录的所有权 # chown –R mysql.mysql /usr/local/mysql # bin/mysql_install_db --user=mysql 修改数据库属主 Chown mysql var Bin/mysqld_safe –user=mysql & Echo ‘/usr/local/mysql/bin/mysqld_safe --user=mysql &’>>/etc/rc.local # ln –s /usr/local/mysql/bin/* /usr/local/bin/ (2).安装Apache 下载地址:http://httpd.apache.org/ # tar –zxvf httpd-2.2.4.tar.gz # cd httpd-2.2.4 # ./configure --prefix=/usr/local/apache --enable-so //编译时加上加载模块参数--enable-so # make # make install #vi /usr/local/apache/conf/httpd.conf //修改Apache 配置文件,添加ServerName www.yourdomain.com(或ServerName 本 机ip) # vi /etc/rc.d/rc.local // 在rc.local 上加入一行/usr/local/apache/bin/apachectl start, 系统启动时启动 Apache 服务。 (3).安装PHP 先安装zlib,freetype,libpng,jpeg 以便于让PHP 支持GD 库( Cacti 的WeatherMap 插件必须要GD 库的支持) 1).安装zlib tar zlib-1.2.3.tar.gz cd zlib-1.2.3 ./configure --prefix=/usr/local/zlib make make install 2).安装libpng tar zxvf libpng-1.2.16.tar.tar cd libpng-1.2.16 cd scripts/ mv makefile.linux ../makefile cd .. make make install 注意,这里的makefile 不是用./configure 生成,而是直接从scripts/里拷一个 3).安装freetype tar zxvf freetype-2.3.4 .tar.gz cd freetype-2.3.4 ./configure --prefix=/usr/local/freetype make make install 4).安装Jpeg tar -zxf jpegsrc-1.v6b.tar.gz cd jpeg-6b/ mkdir /usr/local/libjpeg mkdir /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 参数,不然,不会生成共享库 5).安装libxml,RedHat AS 4 默认安装libxml 包,但版本太低,PHP5 需要更高 版本的libxml 包。 # tar –zxvf libxml2-2.6.25.tar.gz libxml2-devel也要装(RPM) # cd libxml2-2.6.25 # ./configure # make # make install 6).安装Fontconfig (用RPM安装,灰字忽略)扩展包和关联包也装上 tar -zxvf fontconfig-2.4.2.tar.gz cd fontconfig-2.4.2 ./configure --prefix=/usr/local/fontconfig --with-freetype-config=/usr/local/freetype/bin/freetype-config make make install 7).安装GD tar -zxvf gd-2.0.34.tar.gz cd gd-2.0.34 ./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 8).编辑/etc/ld.so.conf,添加以下几行到此文件中。 /usr/local/zlib/lib /usr/local/freetype/lib /usr/local/libjpeg/lib /usr/local/libgd/lib 并执行ldconfig 命令,使用动态装入器装载找到共享库 9).安装PHP tar -zxvf php-5.2.3.tar.gz cd php-5.2.3 # ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/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 #注:如果出现configure: error: cannot find output from lex; giving up,从光盘安装flex包即可解决。-_-!! # make # make install # ln –s /usr/local/php/bin/* /usr/local/bin/ # vi /usr/local/apache/conf/httpd.conf 查找AddType application/x-compress .Z AddType application/x-gzip .gz .tgz 在其下加入AddType application/x-tar .tgz AddType application/x-httpd-php .php AddType image/x-icon .ico 修改DirectoryIndex 行,添加index.php 修改为DirectoryIndex index.php index.html index.html.var # vi /usr/local/apache/htdocs/test.php 添加以下行: <?php Phpinfo(); ?> wq 保存退出。 # /usr/local/apache/bin/apachectl restart 在浏览器中输入:http://www.yourdomain.com/test.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 (1)cd cgilib-0.5 对于0.5版本的cgilib源码部分需做一定的修改: 在 cgi.c 里寻找 #include <malloc.h> ,把那行删掉 修改cgitest.c中116行的错误 116行的代码如下: printf ("<h3>Cookie "Library" set</h3>\n"; 应为代码出错,正确的应是 printf ("<h3>Cookie \"Library\" set</h3>\n"; make make install mkdir -p /usr/local/rrdtool/lb/include cp cgi.h /usr/local/rrdtool/lb/include mkdir -p /usr/local/rrdtool/lb/lib cp libcgi.a /usr/local/rrdtool/lb/lib (2)tar zxf zlib-1.2.3.tar.gz cd zlib-1.2.3 ./configure --prefix=/usr/local/rrdtool/lb make make install tar zxvf libpng-1.2.18.tar.gz (3)cd libpng-1.2.18 ./configure --disable-shared --prefix=/usr/local/rrdtool/lb make make install tar zxvf freetype-2.3.5.tar.gz (4)cd freetype-2.2.5 ./configure --disable-shared --prefix=/usr/local/rrdtool/lb make make install (5)tar zxvf libart_lgpl-2.3.17.tar.gz 用RPM把开发包也装上libart_lgpl-devel.... cd libart_lgpl-2.3.17 ./configure --disable-shared -- prefix=/usr/local/rrdtool/lb make;make install (6)tar xjf intltool-0.40.6.tar.bz2 Cd intltool-0.40.6 ./configure Make;make install (7)tar zxf rrdtool-1.2.23.tar.gz cd rrdtool-1.2.23 ./configure --prefix=/uar/local/rrdtool --disable-tcl && make && make install //完成后建立符号连接 ln –s /usr/local/rrdtool/bin/* /usr/local/bin/ cp /usr/local/lib/libpng.so.0 /usr/lib/ 这步必须有,否则报错找不到此文件。 //执行rrdtool 看是否安装正确 4. 安装net-snmp # tar zxvf net-snmp-5.2.4.tar.gz #cd 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名称。 # /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/ # tar –zxvf cacti-0.8.6j.tar.gz # mv cacti-0.8.6j /usr/loca/apache/htdocs/cacti # vi /usr/local/apache/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/loca/apache/htdocs/cacti/rra //修改cacti 目录所属组 # chgrp –R cacti /usr/loca/apache/htdocs/cacti //添加cron 任务 # crontab –e */5 * * * * /usr/local/bin/php /usr/local/apache/htdocs/cacti/poller.php > /dev/null 2>&1 6. 安装Cactid CACTID 的安装需要以下支持: net-snmp-devel (需要编译安装net-snmp 时添加--enable-developer 选项) mysql mysql-devel (mysql 源文件编译安装后默认支持) openssl-devel (Redhat 默认安装) # tar -zxvf cacti-cactid-0.8.6i.tar.gz # cd cacti-cactid-0.8.6i # ./configure --with-mysql=/usr/local/mysql --with-snmp=/usr/local/net-snmp # make; //这时你将在此目录下看到多出了cactid、cactid.conf 两个文件 # mkdir /usr/local/cactid # cp cactid cactid.conf /usr/local/cactid # vi /usr/local/cactid/cactid.conf //修改cactid 配置文件 DB_Host 127.0.0.1 DB_Database cacti DB_User cacti DB_Pass cacti 7. 数据库配置 #mysql –uroot –p Password: mysql> create database cacti; Query OK, 1 row affected (0.00 sec) mysql> grant all on cacti.* to cacti@localhost identified by “cacti”; Query OK, 1 row affected (0.00 sec) mysql>exit # cd /usr/local/apache/htdocs/cacti # mysql –uroot –p cacti < cacti.sql Password: 补充:#ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so.15.0.0 /usr/lib/libmysqlclient.so.15 #ldconfig 这两句要加上,否则系统无法找到libmysqlclient.so.15库 Chmod 777 /usr/local/apache/htdocs/cacti/log Chmod 777 /usr/local/apache/htdocs/cacti/rra 8. 完成cacti 的安装 1).在浏览器中输入:http://ip/cacti/ 默认用户名:admin 密码:admin 设置cacti用到的命令路径 (责任编辑:南粤论文中心)转贴于南粤论文中心: http://www.nylw.net(南粤论文中心__代写代发论文_毕业论文带写_广州职称论文代发_广州论文网) |