技术头条 - 一个快速在微博传播文章的方式     搜索本站
您现在的位置首页 --> 系统架构 --> cacti+apache+php+mysql+rrdtool搭建流量监控平台

cacti+apache+php+mysql+rrdtool搭建流量监控平台

浏览:5590次  出处信息
1,apache的安装

    详细的不说,傻瓜安装法

    ./configue --prefix=dir/apache2 --enable-so

    (./configure --prefix=/opt/apache --enable-module=so)

    make

    make install

    设置开机启动 vi /etc/rc.d/rc/local  添加:/opt/apache/bin/apachectl start

    配置文件:/opt/apache/conf/httpd.conf  修改:ServerRoot "/opt/apache"      ServerName 192.168.**.**

    出错:apache服务已经开启,但访问不了web页面

    (1).安装linux时要关掉防火墙

    (2).vi /etc/selinux/config  编译SELINUX=disabled

    2,mysql安装,使用mysql二进制版本就行  (或使用RPM包也可)

      shell> groupadd mysql

      shell> useradd -g mysql mysql

      shell> cd /usr/local

      shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf -

      shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql

      shell> cd mysql

      shell> chown -R mysql .

      shell> chgrp -R mysql .

      shell> scripts/mysql_install_db --user=mysql

      shell> chown -R root .

      shell> chown -R mysql data

      shell> bin/mysqld_safe --user=mysql &

    3,php的安装(非常复杂的编译安装)

                                               

    安装PHP步骤: 1:安装freetype,zlib,jpeg,libpng,libiconv,libxml2-2.6.25,Fontconfig

     2:安装gd库

     3:安装php

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

    tar -zxvf fontconfig-2.4.2.tar.gz

    cd fontconfig-2.4.2

    ./configure

    make

    make install

    6).安装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

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

    /usr/local/zlib/lib

    /usr/local/freetype/lib

    /usr/local/libjpeg/lib

    /usr/local/libgd/lib

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

    8).安装libxml

    # tar -zxvf libxml2-2.6.25.tar.gz

    # cd libxml2-2.6.25

    # ./configure

    # make

    # make install

    安装PHP:

    ./configure \'--prefix=/opt/php\' \'--with-apxs2=/opt/apache/bin/apxs\' \'--with-mysql=/usr/local/mysql/\' \'--with-gd\' \'--with-freetype-dir\' \'--with-png-dir\' \'--with-jpeg-dir\'

    make test

    make install

    对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 //支持套接字

    编辑httpd.conf文件

    添加

    AddType application/x-httpd-php .php

    AddType application/x-httpd-php-source .phps

    LoadModule php5_module modules/libphp5.so

    AddHandler php5-script .php

    AddType text/html .php

    DirectoryIndex index.php

    (http://article.21e.cn/有详细的httpd.conf说明)

    然CPOPY PHP的配置文件

    cp ../phpsorcedir/php.ini.dist /usr/local/php/lib/php.ini  (php.ini.dist在解压后的包里)

    修改php.ini文件

    register_globals = On

    ok!重新启动一下apache服务器

    /apachedir/bin/apachectl restart

    然后写个php测试页info.php:内容如下   (info.php存入apache/htdocs)

    

    phpinfo();

    ?>

    正常的话,应该能看到php的信息了,恭喜你的Apche+Mysql+PHP安装成功

    4,rrdtool安装

    需要到http://oss.oetiker.ch/rrdtool/pub/libs/ 这个url上下载

    libpng-1.2.18.tar.gz

    freetype-2.3.5.tar.gz

    libart_lgpl-2.3.17.tar.gz

    zlib-1[1].2.3.tar.gz

    此三个文件

    使用./configure && make && make install安装即可

    从http://oss.oetiker.ch/rrdtool/pub/?M=D下载到rrdtool包

    解压缩下载的rrdtool包,执行

    ./configure --disable-tcl #此处请使用disable-tcl选项,不然make时候会报错

    make && make install

    ./configure --disable-tcl时报错:找不到freetype2.pc和libart-2.0.pc ,find / -name "libart-2.0.pc"时发现,libart-2.0.pc在/usr/local/lib/pkgconfig/路径下,freetype2.pc也一样

    解决:定义变量 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/,再./configure 问题解决

    make $$ make install

    5,cacti的安装

    从http://www.cacti.net/download_cacti.php下载cacti的包

    groupadd cacti                       #建立用户

    useradd -g cacti -s /bin/false cacti

    将cacti解压后移动到apache所在的htdocs目录下就行

    接下来建立cacti用的表

    mysqladmin -u root -p creat cacti    #创建cacti 数据库

    mysql -u root -p cacti < cacti.sql   # 把 cacti.sql的语句在cacti数据库上执行 (这个cacti用户应

                             该和 include/config.php中的用户一样)

    mysql -u root -p mysql               #针对mysql数据库操作

    grant all on cacti.* to cactiuser@localhost identified by \'cacti\';  #授权cactiuser用户的密码是

                                                          cacti可以在localhost上登陆

    flush privileges;                     #刷新权限

    ********************************

    mysql进入

    show databases; 查看数据库

    use cacti;  进入到cacti数据库

    show tables; 查看数据库中的表

    desc 表名;  查看表的详细信息

    use mysql; database changed

    select * from user;查看mysql用户

    ********************************

    编辑cacti目录下include/config.php文件

    $database_type = "mysql";

    $database_default = "cacti";

    $database_hostname = "localhost";

    $database_username = "cactiuser";

    $database_password = "cacti"

    将相应的内容依自己设定的进行更改

    chown -R cactiuser rra/ log/

    crontab -e编辑

    */5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1

    然后就可以通过 http://your-server/cactidir/进行访问了

    以下是安装过程中的一些报错信息和解决方法:

    1.安装php5需要gd2的支持,但在安装过程中,执行编译的时候出现

    aclocal:configure.ac:64: warning: macro `AM_ICONV’ not found in library的错误,

    搜索google得知安装gettext这个包就可以了。

    #yum install gettext gettext-devel

    再执行make编译就好了。

    2.不存在libjpeg.h的文件 提示:jpeglib.h: No such file or directory

    安装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

    3.编译PHP 进行到make test时:

    因为:Bug #20382 [2] (strtotime ("Monday", $date) produces wrong result on DST changeover) [ext/date/tests/bug20382-2.phpt]

    date OO cloning [ext/date/tests/oo_002.phpt]

    iconv stream filter [ext/iconv/tests/iconv_stream_filter.phpt]

    忽略...

    4.启动apache时:

    httpd: Syntax error on line 53 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so  没有这个目录

    查看安装apache的版本  安装时使用的是\'--with-apxs=/usr/local/apache/bin/apxs\' or \'--with-apxs2=/usr/local/apache/bin/apxs\'(根据apache版本决定)

    5.错误:configure: error: libjpeg.(a|so) not found.

    解决:安装 jpegsrc.v6b.tar.gz 和 libpng-1.2.8-config.tar.gz,如果没安装 GD 库,安装 gd-2.0.33.tar.gz ,这个新的默认就支持 gif

    建立软连接:

    find / -name "jpeg.so*"

    ln -s  /usr/lib/libjpeg.so.62  /usr/lib/libjpeg.so    因为PHP编译时只认*.so文件,不认*.so*文件 (非常重要!!!!!!!)

    此时编译:./configure \'--prefix=/opt/php\' \'--with-apxs2=/opt/apache/bin/apxs\' \'--with-mysql\' \'--with-gd-dir\' \'--with-freetype-dir\' \'--with-png-dir=/usr/bin\' \'--with-jpeg-dir=/usr/bin\'

    其中freetype png  jpeg都加上指定路径,以防出错,以上述为例: 

    --with-freetype-dir=/usr/local/freetype

    --with-jpeg-dir=/usr/local/jpeg6

    6.访问页面时:FATAL: Cannot connect to MySQL server on \'192.168.2.158\'. Please make sure you have specified a valid MySQL database name in \'include/config.php\'

    解决:mysql中cacti密码错误 

建议继续学习:

  1. Mysql监控指南    (阅读:19505)
  2. 批量添加主机到cacti+nagios的监控报警系统中    (阅读:13086)
  3. 我常用的主机监控shell脚本    (阅读:11299)
  4. 7 天打造前端性能监控系统    (阅读:9833)
  5. 如何监控HP服务器硬件状态    (阅读:8913)
  6. Cacti 添加 Nginx 监控    (阅读:8716)
  7. Linux下三种常用的流量监控软件对比    (阅读:8492)
  8. Cacti 添加 Memcached 监控    (阅读:7942)
  9. Cacti 添加 Apache 监控    (阅读:7387)
  10. 脚本利用SNMP mib/oid分析网卡流量    (阅读:6937)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
© 2009 - 2024 by blogread.cn 微博:@IT技术博客大学习

京ICP备15002552号-1