Chinaunix首页 | 论坛 | 博客
  • 博客访问: 341013
  • 博文数量: 79
  • 博客积分: 3053
  • 博客等级: 中校
  • 技术积分: 861
  • 用 户 组: 普通用户
  • 注册时间: 2006-02-27 20:43
文章分类

全部博文(79)

文章存档

2012年(3)

2011年(21)

2010年(15)

2009年(40)

分类: LINUX

2011-12-18 20:57:15

 CACTI.0.8.7c 安装和配置
Redhat AS 4.0  2.6.9-34.ELsmp  x86_64 x86_64 x86_64 GNU/Linux    
Red Hat Enterprise Linux AS release 4 (Nahant Update 3)                      

                                         apache 安装
# tar zxvf httpd-2.2.8.tar.gz
# cd httpd-2.2.8
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-deflate --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-modules=all --enable-shared=max --enable-rewrite --enable-static-support --enable-static-htpasswd --enable-static-htdigest --enable-static-rotatelogs --enable-static-logresolve --enable-static-htdbm --enable-static-ab --enable-static-checkgid --enable-vhost-alias --disable-userdir --with-mpm=worker

#make
#make install

                                             mysql安装

下载最新的MySQL
官方网站:
MySQL版本为mysql-5.1.25-rc.tar.gz
#wget
建立mysql用户和组
#useradd mysql
#usermod -G mysql mysql
解压、配置、编译、安装
#mkdir /usr/local/mysql
#mkdir /var/lib/mysql
#tar -zxvf mysql-5.1.25-rc.tar.gz
#cd mysql-5.1.25-rc
#./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql/ --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-mysqld-user=mysql --enable-assembler --with-extra-charsets=all
#make
#make install
#cp support-files/my-medium.cnf /etc/my.cnf

安装默认的库
#/usr/local/mysql/bin/mysql_install_db

库文件
#echo /usr/local/mysql/lib/mysql >> /etc/ld.so.conf
#ldconfig

#chown -R mysql.mysql /usr/local/mysql
#chown -R mysql.mysql /var/lib/mysql


配置自启动
#cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
#/etc/init.d/mysql start
Starting MySQL.                                            [ OK ]

修改密码
#/usr/local/mysql/bin/mysqladmin -uroot password 'newpassword'
#/usr/local/mysql/bin/mysql -uroot -p -hlocalhost
enter password:

*安全配置*
为了数据的安全,可以考虑让MySQL只守候在127.0.0.1上,这样从Internet上就无法直接访问数据库了。
修改/etc/init.d/mysql文件
在start部分找到类似下面这行
$bindir/mysqld_safe -datadir=$datadir -pid-file=$pid_file &

修改成
$bindir/mysqld_safe -datadir=$datadir -pid-file=$pid_file -bind-address=127.0.0.1 &

重起MySQL
#/etc/init.d/mysql restart

最后netstat -ant确认一下:
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN   

OK,到这里MySQL就安装完成了。


1).安装zlib

tar zxvf zlib-1.2.3.tar.tar
cd zlib-1.2.3
./configure --prefix=/usr/local/zlib
make
make install


2).安装libpng

tar zxvf libpng-1.2.18.tar.tar
cd libpng-1.2.18
./configure  --prefix=/usr/local/libpng
make
make install



3).安装freetype

tar zxvf freetype-2.3.5.tar.tar
cd freetype-2.3.5
./configure --prefix=/usr/local/freetype
make
make install


4).安装Jpeg

   tar -zvxf jpegsrc.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).安装Fontconfig

tar -zxvf fontconfig-2.4.2.tar.tar
cd fontconfig-2.4.2
./configure --with-freetype-config=/usr/local/freetype

make
make install


6).安装GD

tar -zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --prefix=/usr/local/libgd --with-png=/usr/local/lib --with-zlib=/usr/local/zlib --with-freetype=/usr/local/freetype --with-jpeg=/usr/local/libjpeg --with-libxml=/usr/local/libxml2

make
make install

编译时显示以下信息:

** Configuration summary for gd 2.0.35:

   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).安装libxml,RedHat AS 4默认安装libxml包,但版本太低,PHP5需要更高版本的libxml包。
      # tar -zxvf libxml2-2.6.31.tar.tar
      # cd libxml2-2.6.31
      # ./configure
      # make
      # make install


9).安装PHP

PHP下载地址:

tar -zxvf php-5.2.5.tar.gz
cd php-5.2.5
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-gd=/usr/local/libgd --enable-gd-native-ttf --with-ttf --enable-gd-jis-conv --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/libjpeg --with-png-dir=/usr/local/lib --with-zlib-dir=/usr/local/zlib --enable-xml --enable-mbstring --enable-sockets

# make
# make install

# cp php.ini-recommended /usr/local/php/lib/php.ini

# ln -s /usr/local/php/bin/* /usr/local/bin/

# vi /usr/local/apache2/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 application/x-httpd-php-source .phps
AddType image/x-icon .ico

修改DirectoryIndex 行,添加index.php

修改为DirectoryIndex index.php index.html index.html.var


#ServerName #把注释掉去并修改为以下

ServerName localhost:80

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


添加以下行:

//php标记(用<代替[)


Phpinfo();

?>

wq保存退出。

# /usr/local/apache2/bin/apachectl -k stop

#/usr/local/apache2/bin/apachectl -k start

在浏览器中输入:进行测试。


对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=/usr   //激活对 png 的支持

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

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

--enable-gd-jis-conv //使JIS-mapped可用,支持日文字体

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

--enable-xml     //支持XML

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

    

1.安装RRDTool

由于rrdtool-1.2.23需要一些库文件支持,故需先安装配置支持的环境,然后编译安装。直接运行以下bash脚本就可以完成安装:
注意:将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放到/root/rrdtool-1.2.23目录下,将脚本保存为/root/rrdtool-1.2.23/rrdtoolinstall.sh,并给执行权限chmod u+x /root/rrdtool-1.2.23/rrdtoolinstall.sh。
以下链接是我重新打好的一个rrdtool-1.2.23的安装包,里面包括了所有用到的库文件和安装脚本,下载解压后执行脚本rrdinstall.sh即可以完成RRDTool的安装。
点击下载rrdtool-1.2.23.tar.gz


# tar zxvf rrdtool-1.2.23.tar.gz
# cd rrdtool-1.2.23
# ./rrdinstall.sh

如果以上脚本安装失败,可以试试以下安装包:


#!/bin/sh
BUILD_DIR=`pwd`
INSTALL_DIR=/usr/local/rrdtool
cd $BUILD_DIR
tar zxf cgilib-0.5.tar.gz
cd cgilib-0.5
make CC=gcc CFLAGS="-O3 -fPIC -I."
mkdir -p $BUILD_DIR/lb/include
cp *.h $BUILD_DIR/lb/include
mkdir -p $BUILD_DIR/lb/lib
cp libcgi* $BUILD_DIR/lb/lib
cd $BUILD_DIR
tar zxf zlib-1.2.3.tar.gz
cd zlib-1.2.3
env CFLAGS="-O3 -fPIC" ./configure --prefix=$BUILD_DIR/lb
make
make install
cd $BUILD_DIR
tar zxvf libpng-1.2.18.tar.gz
cd libpng-1.2.18
env CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS="-O3 -fPIC" \
    ./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install
cd $BUILD_DIR
tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.2.5
env CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS="-O3 -fPIC" \
    ./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install


cd $BUILD_DIR
tar zxvf libart_lgpl-2.3.17.tar.gz
cd libart_lgpl-2.3.17
env CFLAGS="-O3 -fPIC" ./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install

IR=-I$BUILD_DIR/lb/include
CPPFLAGS="$IR $IR/libart-2.0 $IR/freetype2 $IR/libpng"
LDFLAGS="-L$BUILD_DIR/lb/lib"
CFLAGS=-O3
export CPPFLAGS LDFLAGS CFLAGS

cd $BUILD_DIR
tar zxf rrdtool-1.2.23.tar.gz
cd rrdtool-1.2.23
./configure --prefix=$INSTALL_DIR --disable-python --disable-tcl && make && make install


//完成后建立符号连接

ln -s /usr/local/rrdtool/bin/* /usr/local/bin/

//执行rrdtool看是否安装正确

2.安装net-snmp

RedHat默认安装了SNMP服务,但好象没有snmpwalk,snmpget这两个命令,所以需要编译安装NET-SNMP。

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

//修改snmpd.conf(修改COMMUNITY、允许抓取snmp数据的主机、抓取数据范围等)。


# /usr/local/net-snmp/sbin/snmpd     //启动SNMP服务

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

   //在rc.local上加入一行/usr/local/net-snmp/sbin/snmpd,系统启动时启动SNMP服务。


3.安装Cacti

Cacti官方网站:

# tar -zxvf cacti-0.8.7c.tar.gz

# mv cacti-0.8.7c /usr/local/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.cacti /usr/local/apache2/htdocs/cacti/
# chmod  755  /usr/local/apache2/htdocs/cacti/rra.php
# chmod  755  /usr/local/apache2/htdocs/cacti/cmd.php
# chmod  755  /usr/local/apache2/htdocs/cacti/poller.php
# chmod  -R 777  /usr/local/apache2/htdocs/cacti/rra
# chmod  -R 777  /usr/local/apache2/htdocs/cacti/log

//修改cacti目录所属组

# chgrp -R cacti /usr/local/apache2/htdocs/cacti

//为cacti用户添加cron任务

# crontab -ucacti -e

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

注意:首次执行poller.php时请使用cacti用户,否则生成的rrd文件cacti将没有写入权限。

    

4.安装spine

spine 的安装需要以下支持:

net-snmp-devel (需要编译安装net-snmp时添加--enable-developer选项)

mysql              

mysql-devel     (mysql源文件编译安装后默认支持)

openssl-devel (Redhat默认安装)

# tar xvzf cacti-spine-0.8.7c.tar.gz
# cd cacti-spine-0.8.7c
# ./configure --prefix=/usr/local/spine
# make

# vi /usr/local/spine/etc/spine.conf      //修改spine配置文件

DB_Host         127.0.0.1
DB_Database     cacti
DB_User         cacti
DB_Pass         cacti
DB_Port         3306

    

5.数据库配置

#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>flush privileges;

mysql>exit

# cd /usr/local/apache2/htdocs/cacti

# mysql -uroot -p cacti < cacti.sql

Password:

    

6.完成cacti的安装

1).在浏览器中输入:

默认用户名:admin 密码:admin

2).更改密码

3).设置cacti用到的命令路径

snmpwalk Binary Path          /usr/local/ bin/snmpwalk

snmpget Binary Path         /usr/local/ bin/snmpget

RRDTool Binary Path         /usr/local/ bin/rrdtool

PHP Binary Path              /usr/local/bin/php

Cacti Log File Path           /usr/local/apache2/htdocs/cacti/log/cacti.log

Cactid Poller File Path      /usr/local/cactid/cactid





安装出现的问题

1.安装httpd
        1>未安装gcc
        yum install gcc
        2>checking whether to enable mod_deflate ... configure:error: mod_deflate has been requested but can not be built due to prerequisite failures
        yum install zlib-devel
2.install mysql
        1>configure: error: C++ preprocessor "/lib/cpp" fails sanity check
        yum install gcc-c++
        2>checking for termcap functions library... configure: error: No curses/termcap library found
        yum install ncurses-devel               -->Public key for ncurses-devel-5.5-24.20060715.x86_64.rpm is not installed
                一:yum --nogpgcheck install ncurses-devel
                二:rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
        3>$bindir/mysqld_safe -datadir=$datadir -pid-file=$pid_file -bind-address=127.0.0.1 &
        /etc/init.d/mysql里的参数是--
3.install libjpeg
        1>./libtool --mode=compile gcc -O2  -I. -c ./jcapimin.c
        make: ./libtool: Command not found
        make: *** [jcapimin.lo] Error 127
        版本过低造成
        download libtool-2.2.6a.tar.gz
        cd libtool-2.2.6
        ./configure && make && make install
        cd ~/jpeg-6b
        cp /usr/local/share/libtool/config.sub .
        cp /usr/local/share/libtool/config.guess .
        make && make install
4.install fontconfig
        1>tar zxvf pkg-config-0.23.tar.gz
        cd pkg-config-0.23
        ./configure
        make && make install

5.install gd
        1>Libtool library used but `LIBTOOL' is undefined
        重新安装libtool

6.install php
        1>cannot find libmysqlclient_r under /usr/local/mysql
        不是php的问题,是mysql安装时使用了--with-mpm模块,所以编译MYSQL时需要加上--enable-thread-safe-client
        2>/usr/local/zlib/lib/libz.a: could not read symbols: Bad value
        tar zxvf zlib-1.2.3.tar.gz
        cd zlib-1.2.3
        ./configure
        vi Makefile
        找到CFLAGS=-03 -DUSE_MMAP
        再后面加入-fPIC,即变成CFLAGS=-03 -DUSE_MMAP -fPIC
        make
        make install
7.没有最新的监控,原因是因为本地时间不对,本地时间不对是由于虚拟机Cannot access the Hardware Clock via any known method.
没有读到硬件时间
这个以后应该可以通过ntp来解决

阅读(1642) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~