手机版
你好,游客 登录 注册
背景:
阅读新闻

RHEL5.8下cacti-0.8.8a安装过程记

[日期:2012-08-11] 来源:Linux社区  作者:xinghuiru [字体:大 中 小]

cacti简介
    Cacti是基于PHP/MySQL的开源网络监控及绘图工具,它通过SNMP获取数据并使用RRDTool予以存储,然后在需要时利用RRDTool绘图引擎绘图并通过php展示。
   Cacti的操作流程很简单:获取数据-->存储数据-->展示数据。Cacti通过poller获取数据。poller是一个通过调度的方式每隔一段时间(通常为5分钟)执行的程序,它通常通过SNMP来获取远程主机上的数据。

cacti的安装及配置
本文档中的平台是RHEL5.8用到的程序为:
cacti-0.8.8a (安装路径:/web/vhosts/cacti)
httpd-2.4.2 (安装路径:/usr/local/apache)
php-5.4.4 (安装路径:/usr/local/php)
MySQL-5.5.25a (安装路径:/usr/local/mysql)
rrdtool-1.4.7.tar.gz(安装路径:/usr/local/rrdtool)

一、 编译安装lamp平台

(这里不再给出详细步骤,若没有lamp平台以下是一个脚本,执行即可;若已经安装了则跳过此步骤,从“二” 开始即可)
准备工作:
    1、若想支持mcrypt扩展,下载libmcrypt-2.5.7-5.el5.i386.rpm  libmcrypt-devel-2.5.7- 5.el5.i386.rpm 并安装 rpm -ivh libmcrypt-*  
    2、提供了一个httpd服务的脚本,如下,放到/root目录下,命名为httpd.sh
注意:要求php在configure时指定了--enable-sockets选项,否则,cacti将无法运行。

  1. #!/bin/bash  
  2. #  
  3. # httpd        Startup script for the Apache HTTP Server  
  4. #  
  5. # chkconfig: - 85 15  
  6. # description: Apache is a World Wide Web server.  It is used to serve \  
  7. #          HTML files and CGI.  
  8. # processname: httpd  
  9. # config: /etc/httpd/conf/httpd.conf  
  10. # config: /etc/sysconfig/httpd  
  11. # pidfile: /var/run/httpd.pid  
  12.  
  13. # Source function library.  
  14. . /etc/rc.d/init.d/functions  
  15.  
  16. if [ -f /etc/sysconfig/httpd ]; then  
  17.         . /etc/sysconfig/httpd  
  18. fi  
  19.  
  20. # Start httpd in the C locale by default.  
  21. HTTPD_LANG=${HTTPD_LANG-"C"}  
  22.  
  23. # This will prevent initlog from swallowing up a pass-phrase prompt if  
  24. # mod_ssl needs a pass-phrase from the user.  
  25. INITLOG_ARGS="" 
  26.  
  27. # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server  
  28. # with the thread-based "worker" MPM; BE WARNED that some modules may not  
  29. # work correctly with a thread-based MPM; notably PHP will refuse to start.  
  30.  
  31. # Path to the apachectl script, server binary, and short-form for messages.  
  32. apachectl=/usr/local/apache/bin/apachectl  
  33. httpd=${HTTPD-/usr/local/apache/bin/httpd}  
  34. prog=httpd 
  35. pidfile=${PIDFILE-/var/run/httpd.pid}  
  36. lockfile=${LOCKFILE-/var/lock/subsys/httpd}  
  37. RETVAL=0 
  38.  
  39. start() {  
  40.         echo -n $"Starting $prog: "  
  41.         LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS  
  42.         RETVAL=$?  
  43.         echo  
  44.         [ $RETVAL = 0 ] && touch ${lockfile}  
  45.         return $RETVAL  
  46. }  
  47.  
  48. stop() {  
  49.     echo -n $"Stopping $prog: "  
  50.     killproc -p ${pidfile} -d 10 $httpd  
  51.     RETVAL=$?  
  52.     echo  
  53.     [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}  
  54. }  
  55. reload() {  
  56.     echo -n $"Reloading $prog: "  
  57.     if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then  
  58.         RETVAL=$?  
  59.         echo $"not reloading due to configuration syntax error"  
  60.         failure $"not reloading $httpd due to configuration syntax error"  
  61.     else  
  62.         killproc -p ${pidfile} $httpd -HUP  
  63.         RETVAL=$?  
  64.     fi  
  65.     echo  
  66. }  
  67.  
  68. # See how we were called.  
  69. case "$1" in  
  70.   start)  
  71.     start  
  72.     ;;  
  73.   stop)  
  74.     stop  
  75.     ;;  
  76.   status)  
  77.         status -p ${pidfile} $httpd  
  78.     RETVAL=$?  
  79.     ;;  
  80.   restart)  
  81.     stop  
  82.     start  
  83.     ;;  
  84.   condrestart)  
  85.     if [ -f ${pidfile} ] ; then  
  86.         stop  
  87.         start  
  88.     fi  
  89.     ;;  
  90.   reload)  
  91.         reload  
  92.     ;;  
  93.   graceful|help|configtest|fullstatus)  
  94.     $apachectl $@  
  95.     RETVAL=$?  
  96.     ;;  
  97.   *)  
  98.     echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"  
  99.     exit 1  
  100. esac  
  101.  
  102. exit $RETVAL 

接下来就可以执行脚本了

  1. #!/bin/bash  
  2. #  
  3. <<mark 
  4. prepare the source packages  
  5. apr-1.4.6.tar.bz2    
  6. apr-util-1.4.1.tar.bz2  
  7. httpd-2.4.2.tar.bz2   
  8. cmake-2.8.8.tar.gz  
  9. mysql-5.5.25a.tar.gz  
  10. libmcrypt-2.5.7-5.el5.i386.rpm  
  11. libmcrypt-devel-2.5.7-5.el5.i386.rpm  
  12. php-5.4.4  
  13. mark  
  14. ################compileing httpd######################  
  15. #yum -y groupinstall "Development Libraries" "Development Tools" "X Software Development"  
  16. #setenforce 0  
  17. #mkdir /source  
  18. SOURCE=/source  
  19. SysDir=/etc/rc.d/init.d  
  20. PathDir=/etc/profile  
  21.  
  22. cd $SOURCE  
  23. wget http://apache.etoak.com//apr/apr-1.4.6.tar.bz2  
  24. wget http://apache.etoak.com//apr/apr-util-1.4.1.tar.bz2  
  25. wget http://apache.etoak.com//httpd/httpd-2.4.2.tar.bz2  
  26. wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz  
  27. wget http://anduin.linuxfromscratch.org/sources/BLFS/svn/m/mysql-5.5.25a.tar.gz  
  28. wget http://downloads.php.net/stas/php-5.4.4.tar.bz2   
  29.  
  30. tar xf apr-1.4.6.tar.bz2    
  31. cd apr-1.4.6  
  32. ./buildconf  
  33. ./configure --prefix=/usr/local/apr  
  34. make  
  35. make install  
  36.  
  37. cd $SOURCE  
  38. tar xf apr-util-1.4.1.tar.bz2  
  39. cd apr-util-1.4.1  
  40. ./buildconf --with-apr=$SOURCE/apr-1.4.6  
  41. ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr  
  42. make  
  43. make install  
  44.  
  45. cd $SOURCE  
  46. yum -y install pcre-devel  
  47. tar xf httpd-2.4.2.tar.bz2   
  48. cd httpd-2.4.2  
  49. ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-suexec --enable-ssl --enable-rewrite --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-modules-shared=most --enable-mpms-shared=all   
  50. make  
  51. make install  
  52.  
  53. cd $SOURCE  
  54. echo "PidFile  \"/var/run/httpd.pid\" " >> /etc/httpd/httpd.conf  
  55. cp /root/httpd.sh   $SysDir/httpd  
  56. chmod +x $SysDir/httpd  
  57. chkconfig --add httpd  
  58. service httpd start  
  59. echo "PATH=\$PATH:/usr/local/apache/bin" >> $PathDir  
  60. export PATH=$PATH:/usr/local/apache/bin  
  61. echo "MANPATH  /usr/local/apache/man " >> /etc/man.config  
  62. ln -sv /usr/local/apache/include /usr/include/httpd  
  63. service httpd start  
  64.  
  65. #########################compileing mysql###################################  
  66. cd $SOURCE  
  67. tar xf cmake-2.8.8.tar.gz  
  68. cd cmake-2.8.8  
  69. ./bootstrap  
  70. make  
  71. make install  
  72.  
  73. cd $SOURCE  
  74. groupadd -r mysql  
  75. useradd -g mysql -r -d /data/mysql mysql  
  76. tar xf mysql-5.5.25a.tar.gz  
  77. cd mysql-5.5.25a  
  78. cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1  -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLE_PROFILING=1    
  79. make  
  80. make install  
  81.    
  82. cd /usr/local/mysql  
  83. chown -R :mysql .  
  84. mkdir -pv /data/mysql  
  85. chown -R mysql:mysql /data/  
  86. cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf  
  87. cp /usr/local/mysql/support-files/mysql.server $SysDir/mysqld  
  88. chmod +x $SysDir/mysqld  
  89. chkconfig --add mysqld  
  90. scripts/mysql_install_db --user=mysql --datadir=/data/mysql  
  91. sed -i '/\[mysqld\]/a \datadir = /data/mysql' /etc/my.cnf  
  92. sed -i 's/thread_concurrency = 8/thread_concurrency = 2/g' /etc/my.cnf  
  93. echo "PATH=\$PATH:/usr/local/mysql/bin" >> $PathDir  
  94. export PATH=$PATH:/usr/local/mysql/bin  
  95. echo "MATHPATH /usr/local/mysql/man" >> /etc/man.config  
  96. ln -sv /usr/local/mysql/include /usr/include/mysql  
  97. echo " /usr/local/mysql/lib " >> /etc/ld.so.conf.d/mysql.conf  
  98. ldconfig  
  99. service  mysqld start  
  100. cd  
  101. ##########################compiling php#########################  
  102. cd $SOURCE  
  103. tar xf  php-5.4.4.tar.bz2  
  104. cd  php-5.4.4  
  105. ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-sockets  
  106. cd $SOURCE  
  107. make  
  108. make install  
  109. cd $SOURCE  
  110. cp php-5.4.4/php.ini-production /etc/php.ini  
  111. echo "AddType application/x-httpd-php  .php " >> /etc/httpd/httpd.conf  
  112. echo "AddType application/x-httpd-php-source  .phps" >> /etc/httpd/httpd.conf  
  113. sed -i 's/DirectoryIndex index.html/DirectoryIndex index.php index.html/g' /etc/httpd/httpd.conf  
  114. service httpd restart  
  115. cd  
  116. echo "The End!"

 OK,此时lamp平台架构好了

linux
相关资讯       CACTI 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人��有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款