码迷,mamicode.com
首页 > 其他好文 > 详细

企业级监控工具cacti安装配置全过程

时间:2014-12-21 01:59:39      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:cacti 服务器监控

基础信息:

OS:RHEL 5.8

SOFT: apr-util-1.4.1.tar.bz2  cmake-2.8.6.tar.gz  libmcrypt-2.5.8.tar.gz  php-5.4.36.tar.bz2

             rrdtool-1.4.7.tar.tar    apr-1.4.6.tar.bz2     cacti-0.8.8c.tar.gz       httpd-2.4.2.tar.bz2 

             mysql-5.5.22.tar.gz    php-5.4.5.tar.bz2
首先编译安装LAMP平台,建议卸载掉对应rpm包,否则在各程序协作的时候可能会有问题。

  1. install apr and apr-util:

  2. tar xf apr-1.4.6.tar.bz2   

    cd apr-1.4.6 

    ./buildconf 

    ./configure --prefix=/usr/local/apr 

    make 

    make install 

     

    tar xf apr-util-1.4.1.tar.bz2 

     

    cd apr-util-1.4.1   

    ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr 

    make 

    make install 

  3. install apache:

     yum -y install pcre-devel 

    tar xf httpd-2.4.2.tar.bz2  

    cd httpd-2.4.2 

    ./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  

    make 

    make install 

    echo "PATH=\$PATH:/usr/local/apache/bin" >> /etc/profile 

    export PATH=$PATH:/usr/local/apache/bin 

    echo "MANPATH  /usr/local/apache/man " >> /etc/man.config 

    ln -sv /usr/local/apache/include /usr/include/httpd

  4. install cmake:

    tar xf cmake-2.8.8.tar.gz 

    cd cmake-2.8.8 

    ./bootstrap 

    make 

    make install

  5. install mysql

    groupadd -r mysql 

    useradd -g mysql -r -d /data/mysql mysql 

    tar xf mysql-5.5.22a.tar.gz 

    cd mysql-5.5.22a 

    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   

    make 

    make install 

  6. cd /usr/local/mysql 

chown -R :mysql . 

mkdir -pv /data/mysql 

chown -R mysql:mysql /data/ 

cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf 

cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld 

chmod +x /etc/rc.d/init.d/mysqld 

chkconfig --add mysqld 

scripts/mysql_install_db --user=mysql --datadir=/data/mysql 

sed -i ‘/\[mysqld\]/a \datadir = /data/mysql‘ /etc/my.cnf 

sed -i ‘s/thread_concurrency = 8/thread_concurrency = 2/g‘ /etc/my.cnf 

echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile

export PATH=$PATH:/usr/local/mysql/bin 

echo "MATHPATH /usr/local/mysql/man" >> /etc/man.config 

ln -sv /usr/local/mysql/include /usr/include/mysql 

echo " /usr/local/mysql/lib " >> /etc/ld.so.conf.d/mysql.conf 

ldconfig 

service  mysqld start 

6.install php

安装php之前有可能会要求安装libmcrypt,我直接在chinaunix下载的源码 编译安装即可,然后编译PHP时加上 --with-mcrypt=DIR

tar xf  php-5.4.4.tar.bz2 

cd  php-5.4.4 

./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   

make 

make install   

cp php-5.4.4/php.ini-production /etc/php.ini 

echo "AddType application/x-httpd-php  .php " >> /etc/httpd/httpd.conf 

echo "AddType application/x-httpd-php-source  .phps" >> /etc/httpd/httpd.conf 

sed -i ‘s/DirectoryIndex index.html/DirectoryIndex index.php index.html/g‘ /etc/httpd/httpd.conf 

上面所有操作无错误执行完以后可以建个测试php页测试下是不是OK,如果没问题,开始装cacti部分:

 1.我为cacti直接建立的虚拟主机:

首先修改httpd.conf添加:include /etc/httpd/extra/httpd-vhosts.conf

然后修改http-vhosts.conf:

<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/cacti
    ServerName cacti.jerry.com
    ErrorLog "logs/cacti-error_log"
    CustomLog "logs/cacti-access_log" common
</VirtualHost>

2.安装rrdtool:

tar xf rrdtool-1.4.7.tar.gz 

cd rrdtool-1.4.7 

./configure --prefix=/usr/local/rrdtool 

make 

make install 

echo "MANPATH  /usr/local/rrdtool/share/man" >> /etc/man.config 

echo "PATH=$PATH:/usr/local/rrdtool/bin " >> /etc/profile 

export PATH=$PATH:/usr/local/rrdtool/bin 

ln -sv /usr/local/rrdtool/include /usr/include/rrdtool 

echo "/usr/local/rrdtool/lib" >> /etc/ld.so.conf.d/rrdtool.conf 

ldconfig

3.yum安装net-snmp、net-snmp-util并设置自动运行,此处不给详细命令了

4.安装cacti

为cacti创建数据库,并初始化所需要表:

  1. mysqladmin create cacti      //此时的密码为mysql的密码

  2. cd /usr/local/apache/htdocs/cacti  

  3. mysql cacti < cacti.sql


创建mysql用户,使用cacti能访问其cacti数据库

mysql -e "GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY ‘cactiuser‘";

  1. //创建了用户cactiuser 密码也为cactiuser  

  2. mysqladmin -p flush-privileges  

  3. mysql -ucactiuser -p          //验证一下是否正确  

接着创建系统用户cactiuser,以之运行cacti的数据获取和日志记录等工作

  1. useradd cactiuser  

  2. chown -R cactiuser:cactiuser /usr/local/apache/htdocs/cacti/{log,rra}

以cactiuser用户的身份,每5钟获取一次数据:

  1. echo ‘*/5 * * * *  /usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php &> /dev/null‘ > /var/spool/cron/cactiuser  


修改php时区:

  1. vim /etc/php.ini

  2. date.timezone = Asia/Shanghai  


编辑cacti的配置文件include/config.php启用并修改如下行:
//$url_path = "/cacti/";
我们这里将之修改为:
$url_path = "/";

而后在浏览器中打开http://cacti.jerry.com,按提示一步步配置即可完成安装。
密码第一次输入的时候,会让修改密码,用户默认为admin 密码为admin

技术分享

本文出自 “进阶之路---Jerry” 博客,请务必保留此出处http://jerry51886.blog.51cto.com/6021523/1592068

企业级监控工具cacti安装配置全过程

标签:cacti 服务器监控

原文地址:http://jerry51886.blog.51cto.com/6021523/1592068

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!