沈阳格力专卖店 发表于 2019-1-11 08:13:40

Cacti部署指南(v0.8.8)

  本次部署的LAMP主要由RHEL5.5、APACHE2.4.3、PHP5.4.9和MYSQL5.5.27这四部分组成。
  安装后的Cacti首页。
http://blog.运维网.com/attachment/201212/114620875.png
  【安装准备】
  1、卸载已安装LAMP


[*]# rpm -e httpd   
[*]# rpm -e mysql   
[*]# rpm -e php   
[*]# yum -y remove httpd   
[*]# yum -y remove php   
[*]# yum -y remove mysql-server mysql   
[*]# yum -y remove php-mysql

  2、关闭SELINUX和IPTABLES


[*]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config //永久禁用,需要重启生效
[*]# /etc/rc.d/init.d/iptables stop

  【安装apache2.4.3】
  1、如果以前安装过httpd或者yum方式安装了apr和apr-util,都需要卸载


[*]# yum remove apr apr-util httpd

  2、编译和安装apr


[*]# wget -c http://mirror.bjtu.edu.cn/apache//apr/apr-1.4.6.tar.gz
[*]# tar -zxvf apr-1.4.6.tar.gz
[*]# cd apr
[*]# ./configure --prefix=/usr/local/apr-httpd/
[*]# make
[*]# make install

  3、编译和安装apr-util


[*]# wget -c http://mirror.bjtu.edu.cn/apache//apr/apr-util-1.4.1.tar.gz
[*]# tar -zxvf apr-util-1.4.1.tar.gz
[*]# cd apr-util
[*]# ./configure --prefix=/usr/local/apr-util-httpd/
[*]# make
[*]# make install

  4、编译httpd


[*]# wget -c http://apache.etoak.com/httpd/httpd-2.4.3.tar.gz
[*]# tar -zxvf httpd-2.4.3.tar.gz
[*]# cd httpd-2.4.3
[*]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr-httpd --with-apr-util=/usr/local/apr-util-httpd --enable-so --enable-deflate=shared --enable-expires=shared--enable-headers=shared --enable-rewrite=shared --enable-static-support
[*]# make
[*]# make install

  5、如需启动、停止、重启Apache就可以用以下方式


[*]# /usr/local/apache/bin/httpd -k start //启动
[*]# /usr/local/apache/bin/httpd -k stop //停止
[*]# /usr/local/apache/bin/httpd -k restart //重启

  【安装MySQL5.5.28】
  1、安装依赖库gcc、gcc-c++


[*]yum install gcc gcc-c++

  2、编译和安装cmdk


[*]# wget -c http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
[*]# tar -zxvf cmake-2.8.10.2.tar.gz
[*]# cd cmake-2.8.10.2
[*]# ./bootstrap --prefix=/usr/local/cmake
[*]# make
[*]# make install

  3、添加mysql用户和用户组


[*]# groupadd mysql
[*]# useradd -g mysql mysql

  4、安装mysql


[*]# wget -c http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.28.tar.gz
[*]# tar -zxvf mysql-5.5.28.tar.gz
[*]# cd mysql-5.5.28
[*]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DMYSQL_TCP_PORT=3306
[*]# make
[*]# make install
[*]# cp support-files/my-medium.cnf /etc/my.cnf
[*]# /usr/local/mysql/scripts/mysql_install_db --user=mysql
[*]# chown -R root.mysql /usr/local/mysql
[*]# chown -R mysql /usr/local/mysql/data

  5、修改root密码


[*]# /usr/local/mysql/bin/mysqladmin -uroot password '新密码'

  6、启动、停止mysql


[*]# /usr/local/mysql/bin/mysqld_safe --user=mysql & //启动
[*]# /usr/local/mysql/bin/mysqladmin -uroot -p shutdown //停止

  【安装PHP5.4.9】
  1、查询并删除原有PHP


[*]# rpm -q php

  2、安装依赖的库


[*]# yum install libxml2-devel
[*]# wget -c http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
[*]# tar zxvf libiconv-1.14.tar.gz
[*]# cd libiconv-1.14
[*]# ./configure --prefix=/usr/local/libiconv
[*]# make
[*]# make install

  3、编译和安装PHP


[*]# wget -c http://www.php.net/get/php-5.4.9.tar.gz/from/cn2.php.net/mirror
[*]# tar -zxvf php-5.4.9.tar.gz
[*]# cd php-5.4.9
[*]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d --with-openssl --with-zlib --enable-bcmath --with-bz2 --with-curl --enable-ftp --with-gd --enable-gd-native-ttf --with-gettext --with-mhash --enable-mbstring --with-mcrypt --enable-soap --enable-zip --enable-sockets --with-iconv=/usr/local/libiconv --with-mysql=/usr/local/mysql --without-pear
[*]# make
[*]# make install

  4、配置PHP


[*]# cp php.ini-production /usr/local/php/etc/php.ini
[*]# vi /usr/local/apache/conf/httpd.conf
[*]    在#AddType application/x-gzip .gz .tgz下加一行:
[*]    AddType application/x-httpd-php .php
[*]    在#LoadModule foo_module modules/mod_foo.so下加一行: 如果原来有就去掉#号
[*]    LoadModule php5_modulemodules/libphp5.so
[*]    找到DirectoryIndex index.html在后面添加 index.php
[*]    保存httpd.conf文件.
[*]# pkill httpd
[*]# /usr/local/apache/bin/httpd -k start

  5、测试PHP


[*]# vi /usr/local/apache/htdocs/index.php
[*]    输入
[*]    保存index.php文件
[*]    在浏览器上输入http://ip:port/index.php 可以看到PHP版本信息

  【安装rrdtool1.4.7】
  1、设置环境变量


[*]# export BUILD_DIR=/data/tools/postfix_install
[*]# export INSTALL_DIR=/usr/local/rrdtool
[*]# export CFLAGS="-O3 -fPIC"
[*]# export LDFLAGS="-Wl,--rpath -Wl,${INSTALL_DIR}/lib"
[*]# export PKG_CONFIG_PATH=/usr/local/rrdtool/lib/pkgconfig

  2、编译和安装依赖工具库pkgconfig


[*]# wget -c http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz
[*]# tar -zxvf pkg-config-0.23.tar.gz
[*]# cd pkg-config-0.23
[*]# ./configure --prefix=$INSTALL_DIR
[*]# make
[*]# make install

  3、编译和安装依赖工具库zlib


[*]# wget -c http://oss.oetiker.ch/rrdtool/pub/libs/zlib-1.2.3.tar.gz
[*]# tar xzvf zlib-1.2.3.tar.gz
[*]# cd zlib-1.2.3
[*]# ./configure --prefix=$INSTALL_DIR --shared
[*]# make
[*]# make install

  4、编译和安装依赖工具库libpng


[*]# wget -c http://oss.oetiker.ch/rrdtool/pub/libs/libpng-1.2.18.tar.gz
[*]# tar xzvf libpng-1.2.18.tar.gz
[*]# cd libpng-1.2.18
[*]# ./configure --prefix=$INSTALL_DIR
[*]# make
[*]# make install

  5、编译和安装依赖工具库freetype


[*]# wget -c http://oss.oetiker.ch/rrdtool/pub/libs/freetype-2.3.5.tar.gz
[*]# tar xzvf freetype-2.3.5.tar.gz
[*]# cd freetype-2.3.5
[*]# ./configure --prefix=$INSTALL_DIR CFLAGS="-O3 -fPIC"
[*]# make
[*]# make install

  6、编译和安装依赖工具库LibXML2


[*]# wget -c http://oss.oetiker.ch/rrdtool/pub/libs/libxml2-2.6.32.tar.gz
[*]# tar xzvf libxml2-2.6.32.tar.gz
[*]# cd libxml2-2.6.32
[*]# ./configure --prefix=$INSTALL_DIR
[*]# make
[*]# make install

  7、编译和安装依赖工具库fontconfig


[*]# wget -c http://oss.oetiker.ch/rrdtool/pub/libs/fontconfig-2.4.2.tar.gz
[*]# tar xzvf fontconfig-2.4.2.tar.gz
[*]# cd fontconfig-2.4.2
[*]# ./configure --prefix=$INSTALL_DIR --with-freetype-config=$INSTALL_DIR/bin/freetype-config --with-expat-lib=/usr/lib64
[*]# make
[*]# make install

  8、编译和安装依赖工具库pixman


[*]# wget -c http://oss.oetiker.ch/rrdtool/pub/libs/pixman-0.10.0.tar.gz
[*]# tar xzvf pixman-0.10.0.tar.gz
[*]# cd pixman-0.10.0
[*]# ./configure --prefix=$INSTALL_DIR
[*]# make
[*]# make install

  9、编译和安装依赖工具库cairo


[*]# wget -c http://oss.oetiker.ch/rrdtool/pub/libs/cairo-1.6.4.tar.gz
[*]# tar xzvf cairo-1.6.4.tar.gz
[*]# cd cairo-1.6.4
[*]# ./configure --prefix=$INSTALL_DIR --enable-xlib=no --enable-xlib-render=no --enable-win32=no
[*]# make
[*]# make install

  10、编译和安装依赖工具库Glib


[*]# wget -c http://oss.oetiker.ch/rrdtool/pub/libs/glib-2.15.4.tar.gz
[*]# tar xzvf glib-2.15.4.tar.gz
[*]# cd glib-2.15.4
[*]# ./configure --prefix=$INSTALL_DIR
[*]# make
[*]# make install

  11、编译和安装依赖工具库Pango


[*]# wget -c http://oss.oetiker.ch/rrdtool/pub/libs/pango-1.21.1.tar.bz2
[*]# tar jxvf pango-1.21.1.tar.gz
[*]# cd pango-1.21.1
[*]# ./configure --prefix=$INSTALL_DIR --without-x
[*]# make
[*]# make install

  12、编译和安装依赖工具库intltool(此步骤可选)


[*]# yum install perl-XML-Parser
[*]# wget -c http://ftp.gnome.org/pub/gnome/sources/intltool/0.40/intltool-0.40.6.tar.gz
[*]# tar xzvf intltool-0.40.6.tar.gz
[*]# cd intltool-0.40.6
[*]# ./configure
[*]# make
[*]# make install

  13、编译和安装依赖工具库rrdtool


[*]# wget -c http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz
[*]# tar xzvf rrdtool-1.4.7.tar.gz
[*]# cd rrdtool-1.4.7
[*]# ./configure --prefix=$INSTALL_DIR
[*]# make
[*]# make install

  【安装snmp】
  1、检查snmp是否存在


[*]# rpm -qa|grep net-snmp
[*]    net-snmp须安装以下4个包
[*]    net-snmp-libs-5.3.2.2-5.el5.i386
[*]    net-snmp-5.3.2.2-5.el5.i386
[*]    net-snmp-devel-5.3.2.2-5.el5.i386
[*]    net-snmp-utils-5.3.2.2-5.el5.i386
[*]# rpm -ivh elfutils-devel-*
[*]# rpm -ivh beecrypt-*
[*]# rpm -ivh net-snmp-5.3.2.2-5.el5.i386.rpm
[*]# rpm -ivh net-snmp-devel-5.3.2.2-5.el5.i386.rpm
[*]# rpm -ivh net-snmp-utils-5.3.2.2-5.el5.i386.rpm

  2、配置snmp


[*]# vi /etc/snmp/snmpd.conf
[*]    com2sec notConfigUser default public 改为:com2sec notConfigUser 127.0.0.1 public
[*]    access notConfigGroup "" any noauth exact systemview none none 改为:access notConfigGroup "" any noauth exact all none none
[*]# view all included .1 80
[*]    将前面的#注释去掉
[*]    保存snmpd.conf文件

  3、重启snmp服务


[*]# service snmpd restart

  【安装Cacti0.8.8a】
  1、编译和安装cacti


[*]# wget -c http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz
[*]# tar -zxvf cacti-0.8.8a.tar.gz
[*]# mv cacti-0.8.8a /usr/local/apache/htdocs/cacti
[*]# chown -R root.root /usr/local/apache/htdocs/cacti
[*]# /usr/local/mysql/bin/mysql -uroot -p
[*]    mysql> create database cacti;
[*]    mysql> use cacti;
[*]    mysql> source /usr/local/apache/htdocs/cacti/cacti.sql;
[*]    mysql> grant all on cacti.* to root;
[*]    mysql> grant all on cacti.* to root@localhost;
[*]    mysql> grant all on cacti.* to cactiuser;
[*]    mysql> grant all on cacti.* to cactiuser@localhost;
[*]    mysql> set password for cactiuser@localhost=password('cactipw');
[*]# vi /usr/local/apache/htdocs/cacti/include/config.php
[*]    $database_type=“mysql”;
[*]    $database_default=“cacti”;
[*]    $database_hostname=“localhost”;
[*]    $database_username=“cactiuser”;
[*]    $database_password=“cactipw”;

  2、Cacti安装向导


[*](1)访问http://ip:port/cacti 页面显示Cacti Installation Guide信息,点击Next
[*](2)选择“New Install”,并确认所显示的配置信息,没有问题则点击Next
[*](3)各个路径根据自己的安装路径填写,找不着的可以试着用whereis、find之类的命令检索一下,一定要全部填写正确!不然会影响画图,设置完成后点击Finish
[*]      RRDTool Binary Path: /usr/local/rrdtool/bin/rrdtool
[*]      PHP Binary Path: /usr/local/php/bin/php
[*]      snmpwalk Binary Path: /usr/bin/snmpwalk
[*]      snmpget Binary Path: /usr/bin/snmpget
[*]      snmpbulkwalk Binary Path: /usr/bin/snmpbulkwalk
[*]      snmpgetnext Binary Path: /usr/bin/snmpgetnext
[*]      Cacti Log File Path: /usr/local/apache/htdocs/cacti/log/cacti.log
[*]      SNMP Utility Version: NET-SNMP 5.x
[*]      RRDTool Utility Version: RRDTool 1.4.x
[*](4)来到Cacti登录界面,首次登陆默认账号/密码是admin/admin,点击Login,然后系统会强制立即修改密码
[*](5)点击Console->Setting->Paths,填入下列地址
[*]      RRDTool Default Font:
[*]      Spine Poller File Path: /usr/local/apache/htdocs/cacti/poller.php

  3、生成统计图像


[*]# /usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php > /dev/null 2>&1
[*]# ls /usr/local/apache/htdocs/cacti/rra //看看这个目录下面有没有文件存在,有则表示图像生成成功
[*]# crontab -e
[*]# */1 * * * * cactiuser /usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php > /dev/null 2>&1
[*]:wq

  完成以上步骤即可成功使用Cactiv0.8.8对所需要的服务系统进行监控了。



页: [1]
查看完整版本: Cacti部署指南(v0.8.8)