....
http://www.centos.bz/2012/01/cacti-install-tutorials/
Cacti安装详细步骤
文章目录
[隐藏]
- 一、cacti概述
- 二、安装rrdtool
- 三、安装配置net-snmp
- 五、安装LAMP
- 四、安装cacti
一、cacti概述
1. cacti是用php语言实现的一个软件,它的主要功能是用snmp服务获取数据,然后用rrdtool储存和更新数据,当用户需要查看数据的时候用rrdtool生成图表呈现给用户。因此,snmp和rrdtool是cacti的关键。Snmp关系着数据的收集,rrdtool关系着数据存储和图表的生成。
2. Mysql配合PHP程序存储一些变量数据并对变量数据进行调用,如:主机名、主机ip、snmp团体名、端口号、模板信息等变量。
3. snmp抓到数据不是存储在mysql中,而是存在rrdtool生成的rrd文件中(在cacti根目录的rra文件夹下)。rrdtool对数据的更新和存储就是对rrd文件的处理,rrd文件是大小固定的档案文件(Round Robin Archive),它能够存储的数据笔数在创建时就已经定义。
二、安装rrdtool
CentOS-5:
- rpm -ivh http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
- yum install rrdtool -y
CentOS-6:
- rpm -ivh http://apt.sw.be/redhat/el6/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
- yum install rrdtool -y
三、安装配置net-snmp
1、安装net-snmp
- yum install net-snmp net-snmp-libs net-snmp-utils
2、配置net-snmp
修改:
- view systemview included .1.3.6.1.2.1.1
为:
- view systemview included .1.3.6.1.2.1
3、测试net-snmp
- # service snmpd start
- # snmpwalk -v 1 -c public localhost .1.3.6.1.2.1.1.1.0
- SNMPv2-MIB::sysDescr.0 = STRING: Linux cronos 2.4.28 #2 SMP ven jan 14 14:12:01 CET 2005 i686
五、安装LAMP
- yum install httpd php php-mysql php-snmp php-xml php-gd mysql mysql-server
- service httpd start
- service mysqld start
- mysqladmin -uroot password yourpassword
- mysqladmin --user=root --password reload
四、安装cacti
1、下载cacti
- cd /tmp
- wget http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz
- tar xzf cacti-0.8.8a.tar.gz
- mv cacti-0.8.8a /var/www/html/cacti
- cd /var/www/html/cacti
2、创建数据库
- mysqladmin --user=root -p create cacti
3、导入数据库
- mysql -uroot -p cacti < cacti.sql
4、创建数据库用户
- shell> mysql -uroot -p mysql
- mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactipassword';
- mysql> flush privileges;
5、配置include/config.php
- $database_type = "mysql";
- $database_default = "cacti";
- $database_hostname = "localhost";
- $database_username = "cactiuser";
- $database_password = "cactipassword";
- /* load up old style plugins here */
- $plugins = array();
- //$plugins[] = 'thold';
- /*
- Edit this to point to the default URL of your Cacti install
- ex: if your cacti install as at http://serverip/cacti/ this
- would be set to /cacti/
- */
- $url_path = "/cacti/";
- /* Default session name - Session name must contain alpha characters */
- #$cacti_session_name = "Cacti";
6、设置目录权限
- chown -R cactiuser rra/ log/
cactiuser为系统存在的用户,为了收集数据。
7、配置计划任务
- echo "*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1">>/etc/crontab
- service crond restart
8、完成cacti的安装
1) 在浏览器中输入:http://www.yourdomain.com/cacti/
默认用户名:admin 密码:admin
2) 更改密码
3)设置cacti用到的命令路径
至此,cacti的安装已经完成,服务器流量监控设置可以参考http://www.centos.bz/2012/06/cacti-monitor-traffic/。
参考:http://docs.cacti.net/manual:087:1_installation.1_install_unix
==========================
http://www.centos.bz/2012/06/cacti-monitor-traffic/
使用cacti监控服务器流量
上次www.centos.bz已经详细介绍如何安装cacti了,这次我们来学习如何简单地配置cacti来监控服务器流量。
下面是cacti的工作流程图:
1、登录cacti,点击“Devices”,然后点击”Add”创建设备,如图:
2、然后输入Description,Hostname,Host Template选择“Generic SNMP-enabled Host”,SNMP Version一般选择“Version 1”(当然得根据你具体的snmp如何配置)。完成后点击”create”创建设备,如图:
4、接着在顶部点击“Create Graphs for this Host”创建图表,如图:
5、在“SNMP – Interface Statistics”下面会显示你的网卡,选择其中一个监控即可,我们这里选”eth0″,之后单击“create”。
6、现在已经成功创建图表,我们点击左侧的“Graph Management”查看图表列表,此时已经可以看到刚才创建的图表,点击相应的图表标题进去查看。
7、现在可能图表还没开始生成,最多等待5分钟,5分钟后图表是创建了,但图表没有数据,需要等待一段时间程序收集数据。
==========================
http://www.xx24578.com/archives/2034
linux下cacti一键自动安装脚本(适用于centos、redhat)—转
xx24578 Linux平台 linux安装脚本0Comments发表评论
http://hi.baidu.com/%C9%E1%B5%C30710/blog/item/654 cbd4d600a28edd72afcb4.html#0 上周接到一个要搭建一个内部系统监控的系统的通知,公司再外网的黑龙江的已经有了一套,是用cacti搭建的,不多想这回的内部肯定也是用cacti了,说句实话cacti用了n多次,感觉很方便,但是对我来说安装确是一件头痛大事,在网上一搜是有一大堆教程,但是仔细看看各个教程发现内容,笔调都差不多连错的都是一样,天下文章一大抄这话自有他的道理,抄就算了,还抄错的,那时候可苦的我,做了一遍又一遍都不成功,相信安装过cacti的人都知道装一个cacti得需要编译一大堆包,特别是在php那一块还有一大堆的编译参数,头都是痛的。
想到了以前还下过一个cactiEZ的东西,傻瓜化安装(连操作系统都自带装好了)确实很方便,方便是方便但是你不能每次装cacti都用那玩意装一个新机器吧,而且公司的要求每台机器的系统须是64位的,分析了一下cactiEZ的kickstart文件,最后写了这么一个脚本,真正的实现一键安装。
安装注意事项:
1.需有yum工具!!(本来想写一个rpm包的版本,发现rpm包的依赖性关系装起来相当费劲,即使加上force参数也会发现后期有很多麻烦,所以推荐yum。centos自带yum,如果机器联网直接执行yum命令即可。如果是redhat的5.0以上系统的可以搭建本地yum源,不会的点击这个链接《redhat 5.3本地yum源的搭建》)
安装过程(共三步):
1.上传我的包autocacti.zip到服务器上面。解压包
unzip autocacti.zip
2.执行安装
sh autocacti/install.sh
3.搞定!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
如下是install.sh脚本的详细内容
#!/bin/bash
#This is automatically installed CACTI
#Author:chenming
#http://llog.cn
#Date:2010.08.20
# Install LAMP+SNMP+GD_
#yum -y install http*
#yum -y install mysql*
#yum -y install php*
#yum -y install net-snmp*
#yum -y install libart_lgpl*
#yum -y install ntp-*
yum -y install httpd mod_ssl mysql-server mysql mysql-devel php php-mysql php-gd php-snmp php-pear php-ldap net-snmp net-snmp-devel net-snmp-utils net-snmp-libs net-snmp-utils net-snmp-perl libart_lgpl ntp
# Installation cacti
unzip cacti.zip > /dev/null
cp -R cacti /var/www/html/ > /dev/null 2>/dev/null
cp -R var/* /var/ > /dev/null 2>/dev/null
cp -R etc/* /etc/ > /dev/null 2>/dev/null
# Installation rrdtool
cp -R usr/* /usr/ > /dev/null 2>/dev/null
ln -s /usr/local/rrdtool/bin/rrdtool/usr/local/bin/rrdtool
# Import Mysql
service mysqld start
/usr/bin/mysqladmin -u root create cacti
mysql -e “GRANT ALL ON cacti.* TO IDENTIFIED BY ‘cacti_cm’”
mysql cacti/tmp/crontab2.tmp
echo ‘*/1 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1′ >> /tmp/crontab2.tmp
echo ’0 1 * * * /var/www/backup.sh’ >> /tmp/crontab2.tmp
crontab /tmp/crontab2.tmp
rm /tmp/crontab2.tmp
echo “alias ipv6 off” >> /etc/modprobe.conf
echo “alias net-pf-10 off” >> /etc/modprobe.conf
setenforce 0
# Starting related services
for service in httpd mysqld snmpd crond
do
service $service restart
chkconfig –level 235 $service on
done
# Related Tips
echo “”
echo “”
echo “Install Successed, Now you can enter http://`ifconfig | grep Bcast | sed ‘s/^.*addr://’ | sed ‘s/ B.*$//’`/cacti”
################################################################
==========================
http://www.oplinux.com/?p=795
在安装cacti网络监控软件之前所需要的一个环境,即在安装过程中所需要的软件包及系统的一些基本安全设置如果系统是一个现成的LAMP网站的话,那么只需要重编译一下php即可。下面是一个全新的cacti服务器安装过程:
Apache2+mysql+php+Zend+gd2+snmp+rrdtool+ cacti-0.8.6j
l 系统的基本安装
(系统的基本安装,可以先从centos中移植一个yum在线升级软件,可以帮你在线完成比较多的包安装,由于centos中的yum库是AS4的加强版所以有些软件有可能没有需手工完成。由于时间的关系有些包的地址可能出现不能下载。)
yum源来自chinalinuxpub.com,用的是centos包,
下载地址: http://www.chinalinuxpub.com/yum.tgz
安装:
tar zxvf yum.tgz
cd yum
rpm -ivh *.rpm
rm -rf /etc/yum.repos.d/CentOS-Base.repo
vi /etc/yum.conf
加入:
#released updates
[update]
name=Red Hat Enterprise AS release 4 Updates
baseurl=http://ftp.chinalinuxpub.com/redhat/enterprise/updates/4AS/
gpgcheck=1
gpgkey=http://ftp.chinalinuxpub.com/redhat/enterprise/RPM-GPG-KEY-linuxpub
#released base
[base]
name=Red Hat Enterprise AS release 4 Updates
baseurl=http://ftp.chinalinuxpub.com/redhat/enterprise/os/i386/RedHat/
gpgcheck=1
gpgkey=http://ftp.chinalinuxpub.com/redhat/enterprise/RPM-GPG-KEY-linuxpub
然后就可以正常使用yum了.
1) 升级OpenSSL
# cd /usr/local/src
# wget http://download.discuz.net/env/openssl-0.9.7j.tar.gz //ssl加密
# wget http://download.discuz.net/env/openssh-4.2p1.tar.gz //ssh下不了可以到网上下
# tar xzvf openssl-0.9.7j.tar.gz
# cd openssl-0.9.7j
# ./config –prefix=/usr/local/openssl //指定安装目录
# make
# make test //编译测试
# make install
# cd ..
2) 升级OpenSSH
# tar xzvf openssh-4.2p1.tar.gz
# cd openssh-4.2p1
# ./configure –prefix=/usr/local/openssh –with-pam –with-zlib=/usr/local/zlib –with-ssl-dir=/usr/local/openssl –with-md5-passwords
# make
# make install //pam存贮模块 ssl加密技术 md5加密 –dir为自动查找目录
注意:安装openssh如果在些过程中的zlib版本比较低则会出现安装失败,建议升级zlib可以是rpm包或是tar包,如果openssh用tar包安装则需要把sshd加到/etc/rc.d/rc.local中让其自动启动,如echo “/usr/local/openssh/bin/sshd” >> /etc/rc.d/rc.locad不要加start这是一个特殊的地方。还有如果测试openssh是否安装成功,启动需要用绝对路径,否则启动不起来。
3)禁止root直接远程登录,此处先建立一个普通系统用户:
# useradd username
# passwd username
# vi /etc/passwd (将passwd文件中username的登录shell改为/bin/sh)
# vi /usr/etc/sshd_config (将#protocol 1,2一行改为protocol 2)
# vi /usr/etc/sshd_config (将#PermitRootLogin yes一行改为PermitRootLogin no)
# /etc/rc.d/init.d/sshd restart
ssh的配置文件是放在/etc/ssh目录下
相关软件下载地址
http://ftp.gnome.org/pub/GNOME/sour…2-2.6.19.tar.gz
http://ftp.gnome.org/pub/GNOME/sour…t-1.1.15.tar.gz
http://downloads.activestate.com/Ac…-i686-linux.rpm
http://curl.haxx.se/download/curl-7.15.0.tar.gz
http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
http://keihanna.dl.sourceforge.net/…e-2.1.10.tar.gz
http://www.ijg.org/files/jpegsrc.v6b.tar.gz
http://nchc.dl.sourceforge.net/sour…ng-1.2.8.tar.gz
http://www.zlib.net/zlib-1.2.3.tar.gz
1) LibXML2
# cd /usr/local/src
# wget http://download.discuz.net/env/libxml2-2.6.24.tar.bz2
# tar xjvf libxml2-2.6.24.tar.bz2
# cd libxml2-2.6.24
# ./configure –prefix=/usr/local/libxml2 //指定一个目录
# make
# make install
l 安装GD库(让PHP支持GIF,PNG,JPEG)
a.安装 jpeg6
建立目录:()
# mkdir -p /usr/local/jpeg6
# mkdir -p /usr/local/jpeg6/bin
# mkdir -p /usr/local/jpeg6/lib
# mkdir -p /usr/local/jpeg6/include
# mkdir -p /usr/local/jpeg6/man
# mkdir -p /usr/local/jpeg6/man1
# mkdir -p /usr/local/jpeg6/man/man1
# cd /usr/local/src
# tar -zvxf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure –prefix=/usr/local/jpeg6/ –enable-shared –enable-static
# make; make install
b.安装libpng
# cd /usr/local/src
# tar -zvxf libpng-1.2.8.tar.gz
# cd libpng-1.2.8
# cp scripts/makefile.std makefile
# make; make install
c.安装 freetype
# cd /usr/local/src
# tar -zvxf freetype-2.1.10.tar.gz
# cd freetype-2.1.10
# mkdir -p /usr/local/freetype
# ./configure –prefix=/usr/local/freetype
# make;make install
d.:安装zlib(如果前面有装过则不用再装)
# cd /usr/local/src
#tar -zxvf zlib-1.2.3.tar.gz
#cd zlib.1.2.3
# ./configure
# make;make install
e.安装GD库
# cd /usr/local/src
# wget http://download.discuz.net/env/gd-2.0.33.tar.gz
# tar xzvf gd-2.0.33.tar.gz
# cd gd-2.0.33
# ./configure –prefix=/usr/local/gd2 –with-jpeg=/usr/local/jpeg6/
–with-png=/usr/local/lib/
–with-zlib=/usr/local/lib/
–with-freetype=/usr/local/freetype/
# make; make install
f. 安装Curl库
# cd /usr/local/src
# tar -zxf curl-7.15.0.tar.gz
# mkdir -p /usr/local/curl
# ./configure –prefix=/usr/local/curl
# make; make install
l 安装apache2+mysql+php+zend
0) 下载软件 :软件可以到
# cd /usr/local/src
# wget http://download.discuz.net/env/httpd-2.0.58.tar.bz2
# wget http://download.discuz.net/env/m … 2-linux-i686.tar.gz
# wget http://download.discuz.net/env/php-5.1.4.tar.bz2
# wget http://download.discuz.net/env/Z … glibc21-i386.tar.gz
1) 安装MySQL (这几个软件里面mysql-5.0.22是编译过的包,可以直接用不用再配置了 )
# tar xzvf mysql-standard-5.0.22-linux-i686.tar.gz
# grep mysql /etc/passwd //没有的话就建一个
# useradd mysql
# mv mysql-standard-5.0.22-linux-i686 /usr/local/mysql 把mysql移动并改名
# cd /usr/local/mysql
# scripts/mysql_install_db –user=mysql //初始化数据库
# chown -R root . //将scripts变成root权限R为目录下的所有文件
# chown -R mysql data //将data目录变成mysql权限
# chgrp -R mysql . //把/usr/local/mysql目录变成mysql组权限
# mv data /var/lib/mysql //把数据库移到/var/lib/mysql目录下
# ln -s /var/lib/mysql ./data //把做个连接,接在一起
# cp support-files/my-large.cnf /etc/my.cnf //把配置文件放到/etc/my.cnf中
# bin/mysqld_safe –user=mysql & //启动mysqld服务,&为启动别的mysql进程
# bin/mysqladmin -u root password‘newpassword’ //给mysqladmin设一个root权限
# bin/mysqladmin -u root -p //测试mysql是否成功
# cp support-files/mysql.server /etc/init.d/mysqld //拷到配置目录做为启动服务
# chkconfig –add mysqld //添加做为后台服务
# /etc/rc.d/init.d/mysqld start //有了以上的两条可以直接从这里启动
注意:set password for ‘root’@'localhost’ = old_password(’123456′); 一定要否则会出现密码出错。创建:create database sqlname;使用过程中用mysql –u root –p回车;
2) 编译安装Apache
# cd /usr/local/src
# tar xjvf httpd-2.0.58.tar.bz2
# cd httpd-2.0.58
# ./configure –prefix=/usr/local/apache2
–mandir=/usr/share/man //指定目录与man路径
–enable-module=so //动态模式要用module=so很重要
–enable-deflate=shared
–enable-expires=shared
–enable-rewrite=shared //不一定用到的rewrite先准备着
–enable-gzip //打开高速缓存,文件,内存,磁盘
–enable-cache
–enable-file-cache
–enable-mem-cache
–enable-disk-cache
# make
# make install
/usr/local/apache2/bin/apachectl start //启apache,之后就可以看到羽毛的主页了,是静态的
以上有三条要用的—prefix; module=so; gzip 在跟php整合时要用到
3) 编译安装PHP
安装jpegsrc.v6b.tar.gz 和 libpng-1.2.8-config.tar.gz,否则提示错误”libjpeg.(a|so) not found.”
注意:可以用yum install php-mysql php-snmp 这两个(或是直接装系统的时侯把这些包选上)
这里比较重要,很多文档当中没有指出有几个比较重要的参数:mysql.so;odbc.so;ldap.so;pqsql.so这
些需要先安包,可以用yum在线把这几个包先装上(否则rrdtool读不出图)
# cd /usr/local/src
# tar xjvf php-4.4.4.tar.bz2
# cd php-4.4.4
./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs –with-zlib-dir –with-bz2-dir –with-tiff-dir –with-libxml=/usr/local/libxml2 –with-gd=/usr/local/gd2 –with-freetype=/usr/local/freetype –with-jpeg=/usr/local/jpeg6 –with-png=/usr/local/libpng –with-ttf –enable-mbstring –with-mysql =/usr/local/mysql –with-config-file-path=/etc –enable-sockets –with-snmp-dir –enable-ucd-snmp-hack –disable-ipv6 –enable-gd-native-ttf –with-ldap-dir –with-mysql-dir –with-odbc-dir –with-pgsql-dir
Php配置比较重要
4) 安装Zend Optimizer
# cd /usr/local/src
# tar xzvf ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz
# ./ZendOptimizer-3.0.1-linux-glibc21-i386/install.sh
l SNMP安装和配置
先查看是否有这些包
可以直接使用yum install net-snmp
#rpm -qa | grep net-snmp
#net-snmp-5.0.9-2.30E.15
#net-snmp-devel-5.0.9-2.30E.15
#net-snmp-libs-5.0.9-2.30E.15
#net-snmp-utils-5.0.9-2.30E.15
需要修改snmpd.conf配置文件
vi /etc/snmp/snmpd.conf
修改如下两行
com2sec notConfigUser 127.0.0.1 public
access notConfigGroup “” any noauth exact mib2 none none
去掉下面几行前面的”#”
com2sec local localhost COMMUNITY
com2sec mynetwork NETWORK/24 COMMUNITY
group MyRWGroup any local
group MyROGroup any mynetwork
view all included .1 80
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
access MyROGroup “” any noauth 0 all none none
access MyRWGroup “” any noauth 0 all all all
开启: setup
在system service选中snmp
执行service snmpd start
******************************************************************
或是在安装snmp时直接给snmp.conf里面写上几条配置
com2sec local 127.0.0.1 public
group MyROGroup v1 local
group MyROGroup v2 local
group MyROGroup usm local
view all included .1.3.6.1.2.1.2 80
access MyROGroup “” any noauth exact all none none
************************************************************************
可以执行snmpwalk 或是snmpget进行测试
snmpwalk -c public -v2cyour_host_ip if
使用以上的命令如果有出现:则表现net-snmp安装成功
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.16777219 = INTEGER: 16777219
IF-MIB::ifIndex.16777220 = INTEGER: 16777220
IF-MIB::ifDescr.1 = STRING: MS TCP Loopback interface
IF-MIB::ifDescr.16777219 = STRING: Intel(R) 82540EM Based Network Connection
IF-MIB::ifDescr.16777220 = STRING: Intel(R) PRO Adapter
IF-MIB::ifType.1 = INTEGER: softwareLoopback(24)
IF-MIB::ifType.16777219 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.16777220 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifMtu.1 = INTEGER: 1500
IF-MIB::ifMtu.16777219 = INTEGER: 1500
IF-MIB::ifMtu.16777220 = INTEGER: 1500
IF-MIB::ifSpeed.1 = Gauge32: 10000000
l rrdtool-1.2.11安装
rrdtool包站点的地址已改变不过可以直接链接到http://oss.oetiker.ch/rrdtool/download.en.html
安装libart
wget http://people.ee.ethz.ch/~oetike … _lgpl-2.3.17.tar.gz
tar zxvf libart_lgpl-2.3.17.tar.gz
cd libart_lgp-2.3.17
./configure
make
make install
安装 libcgi
wget http://lists.ee.ethz.ch/p/cgilib-0.5.1.tar.gz
tar zxvf cgilib-0.5.1.tar.gz
cd cgilib-0.5.1
make
make install
cp libcgi.a /usr/local/lib
cp cgi.h /usr/include
安装 rrdtool
wget http://people.ee.ethz.ch/~oetike … dtool-1.2.14.tar.gz
tar zxvf rrdtool-1.2.14.tar.gz
cd rrdtool-1.2.14
./configure –prefix=/usr/local/rrdtool-1.2.14 \
–disable-tcl \
–disable-python
make && make install
***********************************************************************
或是直接从官网上下载rpm包有五个直接用rpm包也可以rpm -Uvh *.rpm
也可搞定不过装完之后是英文版
***********************************************************************
l 安装/ 配置cacti
1.设置mysql
创建数据库、数据库用户,调整权限、密码:
# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10 to server version:4.0.23-standard
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql>; create database cactidb;
Query OK, 1 row affected (0.00 sec)
mysql>; grant all on cactidb.* to root;
Query OK, 0 rows affected (0.01 sec)
mysql>; grant all on cactidb.* to root@localhost;
Query OK, 0 rows affected (0.01 sec)
mysql>; grant all on cactidb.* to cactiuser;
Query OK, 0 rows affected (0.00 sec)
mysql>; grant all on cactidb.* to cactiuser@localhost;
Query OK, 0 rows affected (0.01 sec)
mysql>; set password for cactiuser@localhost=old_password(’cactipw’);
Query OK, 0 rows affected (0.00 sec)
mysql>; exit
# useradd cactiuser -g users
# passwd cactiuser (pwd:cactipw)
# cp cacti-0.8.6j.tar.gz /usr/local/apache2/htdocs //具本目录为安装apache2的目录
# cd /usr/local/apache2/htdocs
# tar zxvf cacti-0.8.6j.tar.gz
# mv cacti-0.8.6j cacti
# cd cacti
# /usr/local/mysql/bin/mysql -u root -pmysql cactidb < cacti.sql
# chown -R cactiuser rra/ log/
# cd scripts
# chown cactiuser:users *
# vi /www/htdocs/cacti/include/config.php
$database_type = “mysql”;
$database_default = “cactidb”;
$database_hostname = “localhost”;
$database_username = “cactiuser”;
$database_password = “cactipw”;
更改用户、密码 等项 与上面给出的对应 保存退出
让系统每五分钟运一次
# crontab -u cactiuser -e
加入
*/5 * * * * /usr/local/php/bin/php /usr/local/apache2/htdocs/cacti/poller.php > /dev/null 2>&1
保存退出:wq
全部设置完毕。
打开浏览器 http://your ip/cacti 进入cacti的初始设置页面
第一次默认登陆账号:admin 密码 admin
登陆后在新改个密码就OK
需要说明的还有路径
==========================
***************************************************************
http://zephyrxt.com/bbs/thread-9415-1-1.html
时间:2010-02-04 01:20:41
####################################
#Cacti Configuration
#Date: 2009-11-04
#Env: Centos 5.4 x86_64
#Author:
http://www.chengyongxu.com/blog/centoscacti%E5%9F%BA%E6%9C%AC%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/
####################################
一、准备工作
环境:Centos 5.4 x86_64
所需软件:
http
Php
Php-mysql
Php-snmp
Mysql
Perl-DBD-MySQL
Php-pdo
rrdtool
Net-snmp
Net-snmp-libs
Net-snmp-utils
#下载相关软件
cd /usr/local/src/
wget http://www.cacti.net/downloads/cacti-0.8.7e.tar.gz
二、环境介绍
主监控机是Centos 5.4 x86_64
主监控机IP=10.0.0.52
三、安装配置
(1)在主监控机上安装apache+php+gd的web环境,推荐编译安装,不再赘述,本处方便起见用yum装了
yum install php php-mysql php-snmp mysql mysql-server net-snmp net-snmp-libs net-snmp-utils php-pdo perl-DBD-MySQL
(2)在主监控机上安装rrdtool,rrdtool依赖的包过多,所以选择增加源,然后用yum安装
#增加源
vi /etc/yum.repos.d/CentOS-Base.repo
#在文件末尾增加以下部分
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
enabled=1
yum install rrdtool
(3)配置snmp
vi /etc/snmp/snmp.conf
#将下边这行中的default
com2secnotConfigUser default public
#改为127.0.0.1
com2secnotConfigUser 127.0.0.1 public
#将下边这行中的systemview
access notConfigGroup "" any noauth exact systemview none none
#改为all
access notConfigGroup "" any noauth exact all none none
#将下边这行的注释“#”号去掉
#view all included .1 80
#重启snmpd服务
service snmpd restart
(4)安装cacti
#把解压后的包移动到你的相应的web目录
tar xvf cacti-0.8.7e.tar.gz
mv cacti-0.8.7e /var/www/html/cacti
(5)在数据库中建库、授权、导入数据库结构
#注意导入cacti.sql时该文件的路径
mysql -p
mysql> create database cacti;
mysql> grant all privileges on cacti.* to cacti@localhost identified by 'cacti' with grant option;
mysql> grant all privileges on cacti.* to cacti@127.0.0.1 identified by 'cacti' with grant option;
mysql> use cacti;
mysql> source /var/www/html/cacti/cacti.sql;
#配置cacti以连接数据库
vi /var/www/html/cacti/include/config.php
(6)浏览器下配置
#用浏览器打开 http://10.0.0.52/cacti ,会显示 cacti的安装指南,设置好就不会再出现了。
#点击 “Next”
#选择“New Install”,点击“Next”
#指定 rrdtool、 php、 snmp 工具的 Binary 文件路径,确保所有的路径都是显示“ FOUND”,没有 “NOT FOUND”的,点击 Finish 完成安装。
#Cacti 默认的用户名与密码是 admin,输入用户名与密码,点击 login
#为了安全的原因,第一次登录成功后,cacti 会强制要求你更改一个新的 password ,输入新密码并确认密码,点击 save ,进入 cacti 控制台界面:
#点击 graphs ,查看cacti 监控本机的图表:
(7)增加入一个计划任务,使得 cacti 每五分钟生成一个监控图表。
crontab -e
#加入如下内容。注意poller.php的路径
*/5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1
#确保 /var/www/html/cacti/rra/目录存在
#如果暂时未看到图表,可以手工执行,生成图表
#php /var/www/html/cacti/poller.php > /dev/null 2>&1
(8)使用 Cacti 监控 Linux 主机
#在被监控的linux主机上安装net-snmp
yum install net-snmp
vi /etc/snmp/snmpd.conf
#更改以下部分
#将下边这行中的default
com2secnotConfigUser default public
#改为10.0.0.52(cacti)服务器的地址)
com2secnotConfigUser 10.0.0.52 public
#将下边这行中的systemview
access notConfigGroup "" any noauth exact systemview none none
#改为all
access notConfigGroup "" any noauth exact all none none
#将下边这行的注释“#”号去掉
#view all included .1 80
service snmpd restart
(9)如果出现问题请注意一下snmp协议的版本,都用version 1是一种解决方法
如果都用version 1,需要把所有监控机和被监控机的snmpd.conf改一下
#vi /etc/snmp/snmpd.conf
#将下边这行
view systemview included .1.3.6.1.2.1.1
#改为
view systemview included .1.3.6.1.2.1
****************************************************************
==========================
==========================
==========================
http://bbs.chinaunix.net/thread-3735788-1-1.html
本帖最后由 tjz2000 于 2012-05-19 00:00 编辑
Yunweiw.com-Cacti+Nagios 是由运维网集成制作发布的一个基于CentOS 6.2系统集成Cacti及Nagios的全自动安装系统,省去了自行安装的麻烦,并集成了我们最常用的插件,足以应付我们日常的工作需要。
集成Syslog、monitor、thold、manage、weathermap等近40个Cacti实用的插件
集成更多的Cacti模板,有Apache模板、Nginx模板、MySQL模板、打印机模板、多CPU图合一模板等……
集成飞信机器人可短信报警
还集成pnp4nagios哦……
集成Nconf在线配置 Nagios(PHP写的Web方式配置Nagios的工具)
集成简单实用的MySQL数据库管理工具phpMyAdmin等实用工具
永不停止,持续更新,保持与Cacti、Nagios官方同步……
使用方法:
安装后默认IP地址是192.168.0.8,登录后即可使用
登录:http://192.168.0.8
用户:admin
密码:www.yunweiw.com
更多详解信息可以登录以下地址进行查看
Yunweiw.com-Cacti+Nagios下载地址
http://www.yunweiw.com/bbs/viewthread.php?tid=217&extra=page%3D1
Yunweiw.com-Cacti+Nagios安装说明
http://www.yunweiw.com/bbs/viewthread.php?tid=213&extra=page%3D1
Yunweiw.com-Cacti+Nagios安装后按自己的相关要求修改相关信息
http://www.yunweiw.com/bbs/viewthread.php?tid=249&extra=page%3D1 |
==========================
==========================
==========================
#######################################################################
http://hi.baidu.com/learn2008/blog/item/df0779542c73763f3b293523.html
centos下yum安装cacti
2012-05-10 0:28
OS:CentOS 32位 5.6
DataBase:MySQL5.0
PHP Apache
net-snmp
部署CentOS cacti配置需要的环境
安装MySQL
yum -y install mysql
yum -y install mysql-server
yum -y install mysql-devel
安装apache
yum -y install httpd
安装php
yum -y install php
yum -y install php-mysql
启动各类服务并且加入启动列表
service httpd start
service mysqld start #第一次启动会初始化MySQL的数据字典
chkconfig httpd on
chkconfig mysqld on
由于CentOS cacti配置的运行需要大量的其它库的支持,我们还需要安装一些:
zlib:
yum -y install zlib
libpng:
yum -y install libpng
freetype:
yum -y install freetype
jpeg:
yum -y install libjpeg
fontconfig:
yum -y install fontconfig
gd:
yum -y install gd
libxml:
yum -y install libxml2
yum -y install php-gd //如果weathermap没有正常运行可以检查这个
安装rrdtool
在 /etc/yum.repos.d/下面新建dag.repo文件在文件中输入源地址:
[iyunv@hmg2 yum.repos.d]# cat dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
enabled=1
[iyunv@hmg2 yum.repos.d]#yum -y install rrdtool
启动rrdtool服务并且加入启动列表
service rrdcached start
chkconfig rrdcached on
安装snmp的支持工具
yum -y install net-snmp
yum -y install net-snmp-utils
启动snmpd服务并且加入启动列表
service snmpd start
chkconfig snmpd on
安装CentOS cacti
下载CentOS cacti,cacit官方网站:http://www.cacti.net/download_cacti.php
wget http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz
解压并放到apache文档目录(/var/www/html是默认apache网站目录)
tar -xf cacti-0.8.7g.tar.gz
mv cacti-0.8.7g /var/www/html/cacti
编辑CentOS cacti配置文件,这里配置链接MySQL服务的用户名,密码,端口等。
cd /var/www/html
vi cacti/include/config.php
$database_type = “mysql”;
$database_default = “cacti”;
$database_hostname = “localhost”;
$database_username = “cacti”;
$database_password = “cacti”;
$database_port = “3306″;
添加一个cacti的用户并添加cron任务:
useradd cacti
su – cacti
crontab -e
*/1 * * * * /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1
把cacti网站目录所属组改为cacti:
su – root
chgrp -R cacti /var/www/html/cacti
另外还需要两个目录的所有者修改,以便使cacti有写权限:
chown -R cacti /var/www/html/cacti/rra
chown -R cacti /var/www/html/cacti/log
chown -R cacti /var/www/html/cacti/poller.php
CentOS cacti配置数据库
建立好数据库
访问网页安装,一直next
http://192.168.30.8/cacti安装完成后登陆,初始默认用户名和密码为 admin/admin 登陆后强制改密码为tclportal
CentOS cacti配置数据库
或者
创建CentOS cacti数据库 mysqladmin –user=root create cacti
导入cacit.sql
mysql cacti< /var/www/html/cacti/cacti.sql给cacti用户授权
mysql -uroot
mysql> use cacti
mysql> grant all on cacti.* to cacti@localhost identified by ‘cacti’;
mysql> flush privileges;
mysql> exit
| ==========================
http://www.iyunv.com/os/201107/97230.html
简述:本来是编译安装的,由于编译过程中库文件关联太多,安装文件一定要有顺序性,报错太多,到了rrdtool这一步说什么都安装不过去了,由于时间问题,选择了yum安装,对于编译安装,这个要简单多了,她把关联的文件都自动的安装了,省了不少的事,下边介绍一下yum安装的过程:
首先要部署yum环境,国内有很多yum源,sohu、163、科大的等等,配置很简单,具体的可以到网上查查。
部署环境:(LAMP+RRDTool+snmp+cacti)
一、配置LAMP环境
①安装Mysql
#yum -y install mysql mysql-server mysql-devel
②安装Apache
#yum -y install httpd
③安装PHP
#yum -y install php php-mysql
④启动服务并加入到启动列表
#service httpd start
#service mysqld start
#chkconfig httpd on
#chkconfig mysqld on
二、安装需要的库文件
#yum -y install zlib
#yum -y install zlib
#yum -y install freetype
#yum -y install libjpeg
#yum -y install fontconfig
#yum -y install gd
#yum -y install libxml2
#yum -y install php-gd
三、安装RRDTool
#yum -y install rrdtool
启动rrdtool服务并且加入启动列表
#service rrdcached start
#chkconfig rrdcached on
四、安装snmp支持工具
#yum -y install net-snmp
#yum -y install net-snmp-utils
启动snmpd服务并且加入启动列表
#service snmpd start
#chkconfig snmpd on
五、安装cacti(cacit官方网站:http://www.cacti.net/)
①下载
#wget http://www.cacti.net/downloads/cacti-0.8.7e.tar.gz
②配置
解压并放到apache文档目录(/var/www/html)
#tar -xf cacti-0.8.7e.tar.gz
#mv cacti-0.8.7e /var/www/html/cacti
编辑CentOS cacti配置文件,连接MySQL服务的用户名,密码,端口等。
#cd /var/www/html
#vi cacti/include/config.php
$database_type = “mysql”;
$database_default = “cacti”;
$database_hostname = “localhost”;
$database_username = “cacti”;
$database_password = “cacti”;
$database_port = “3306″;
③添加计划任务(使cacti每5分钟获得一次数据)
添加一个cacti的用户并添加cron任务:
#useradd cacti
#su cacti
#crontab -e
*/1 * * * * /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1
④更改属组
把cacti网站目录所属组改为cacti
#su root
#chgrp -R cacti /var/www/html/cacti
#chown -R cacti /var/www/html/cacti/rra
#chown -R cacti /var/www/html/cacti/log
#chown -R cacti /var/www/html/cacti/poller.php
六、数据库配置
①创建cacti数据库
#mysql
msyql>create database cacti;
②导入cacti.sql
#mysql -u root -p cacti < /var/www/html/cacti/cacti.sql
有密码的输入密码,没密码的直接回车
③应用
mysql> use cacti
mysql> grant all on cacti.* to cacti@localhost identified by ‘cacti’;
mysql> flush privileges;
mysql> exit
七、WEB登陆cacti
①http://ip/cacti
(这里如果出现“403 forbidden”的错误,请把selinux关闭)
打开网页—>next—>选择new install,使用一路回车法.完成
的用户名为: admin 密码为: admin (初次登陆成功会提示更改密码)
八、汉化cacti(如果英文不好的话,可以把cacti汉化,这样看起就就方便了)
①下载
wget http://blogimg.chinaunix.net/blog/upfile2/090815172648.gz
②配置
tar zxvf 90815172648.gz
rm -rf /var/www/html/cacti
mv cacti-0.8.7e-cn-utf8/ /var/www/cacti/html
vi /var/www/cacti/html/include/config.php
内容如下:
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
chown -R cacti /var/www/html/cacti/rra /var/www/html/cacti/log
③升级
http://ip/cacti
选择"从0.8.x升级"选项,然后跟着提示走,就OK了.
登陆,用户名为:admin,密码是你之前改过的,如果没有改的话,仍然是admin.
汉化完成了,接下来就配置自己的应用吧!
------------------------------------------------------------------------------------------------------------------
由于技术有限,所有在安装配置的过程中有哪里不对的,或者是缺少东西的,欢迎大家指点!
==========================
http://www.itkee.com/os/detail-1d7a.html
最近一直在公司搞这个东西,由于各种资料很全(中文的也不少),所以做起来相对容易,也少走了很多弯路。搭好后总结手顺如下。
首先我使用的centOS 5.3,最小安装。
YUM一些必要的RPM包。
# yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers pango-devel net-snmp-devel net-snmp net-snmp-utils net-snmp-libs
MYSQL安装
所有rpm包都安装完成后,就可以安装mysql了。
# tar -xzvf mysql-5.0.45-linux-i686-glibc23.tar.gz
# mv mysql-5.1.38-linux-x86_64-icc-glibc23 /usr/local/mysql
# cd /usr/local/mysql
# groupadd mysql
# useradd -g mysql mysql
# scripts/mysql_install_db --user=mysql //初始化数据库
# chown -R root .
# chown -R mysql data
# chgrp -R mysql .
# ./bin/mysqld_safe --user=mysql & //启动
# ./bin/mysqladmin -u root password admin //给root用户设置密码
# cp ./support-files/mysql.server /etc/init.d/mysqld
# ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql //建立一个软连接,使得可以在命令行下直接使用mysql命令
# ln -s /usr/local/mysql/bin/mysqladmin /usr/local/bin/mysqladmin //建立一个软连接,使得可以在命令行下直接使用mysqladmin命令
# ln -s /usr/local/mysql/bin/mysqldump /usr/local/bin/mysqldump //建立一个软连接,使得可以在命令行下直接使用mysqldump命令
# ln -s /usr/local/mysql/lib/libmysqlclient.so.16 /usr/local/lib/ //建立一个软连接,是其他软件可以找到编译和运行时的库
# /usr/local/mysql/bin/mysql -u root -padmin //进入数据库并给cacti建立一个专用的库cactidb
mysql> create database cactidb;
mysql> grant all on cactidb.* to root;
mysql> grant all on cactidb.* to ;
mysql> grant all on cactidb.* to cactiuser;
mysql> grant all on cactidb.* to ;
mysql> set password for );
mysql> exit
APACHE安装
# tar -zxvf httpd-2.2.6.tar.gz
# cd httpd-2.2.14
# ./configure --prefix=/usr/local/apache --enable-so
# make
# make config
PHP安装
# tar -zxvf php-5.1.6.tar.gz
# cd php-5.1.6
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs --enable-sockets --with-zlib-dir=/usr/include --with-gd
# make
# make install
# cp php.ini-dist /usr/local/php/php.ini
# vi /usr/local/apache/conf/httpd.conf //修改apache的配置文件加入下面几行 用来对php进行支持
找到AddType application/x-gzip .gz .tgz 在它后面添加
AddType application/x-tar .tgz
AddType application/x-httpd-php .php
AddType image/x-icon .ico
找到DirectoryIndex index.html,把这句改成
DirectoryIndex index.php index.html index.html.var
保存退出
# /usr/local/apache/bin/apachectl start //启动 apache
# vi /usr/local/apache/htdocs/ceshi.php //测试页
<?
phpinfo( );
?>
保存退出
浏览器输入http://IP/ceshi.php 看看是否有php的相关信息
SNMP
配置SNMP //注意,此处配置SNMP是用于检测本机的数据,也就是说,如果想用cacti检测其他linux主机,也要在其他linux主机上进行同样的SNMP配置,不然cacti服务器无法获取SNMP数据。
# vi /etc/snmp/snmpd.conf //找到下面几行并修改
找到com2sec notConfigUser default public 改成
com2sec notConfigUser 127.0.0.1 public //default 改为127.0.0.1
(注意这里:如果你以后想往cacti里添加其他机器,只要在被监控的主机上把127.0.0.1改为cacti服务器的地址就行了)
找到access notConfigGroup "" any noauth exact systemview none none 改成
access notConfigGroup "" any noauth exact all none none //systemview 改为all
找到#view all included .1 80 改成
view all included .1 80 //去掉注释
保存退出
# service snmpd restart
测试一下snmpwalk是否正常工作
# snmpwalk -c public -v 1 -m ALL 127.0.0.1 .1.3.6.1.2.1.4.20 //看看得出的数据第一行是不是本机的IP地址
RRDTool安装
# tar -zxvf rrdtool-1.3.6.tar.tar
# cd rrdtool-1.3.6
# ./configure
# make
# make install
CACTI安装
# useradd cactiuser -g users
# tar zxvf cacti-0.8.7e.tar.gz
# mv cacti-0.8.7e /usr/local/apache/htdocs/cacti
# cd /usr/local/apache/htdocs/cacti
# chown -R cactiuser rra/ log/
# cd scripts
# chown cactiuser:users *
# vi /usr/local/apache/htdocs/cacti/include/config.php //找到如下几行
$database_type = “mysql”;
$database_default = “cactidb”; //这里把cacti改成cactidb
$database_hostname = “localhost”;
$database_username = “cactiuser”;
$database_password = “admin”; //这里把cactiuser改成admin
保存退出
/usr/local/mysql/bin/mysql -u root -padmin cactidb < cacti.sql //导入数据库
现在用浏览器访问
http://ip/cacti
出现 Cacti Installation Guide 界面,点next
选择new install
RRDTool Binary Path和PHP Binary Path应该会显示NOT FOUND
手动在这两个输入
c
/usr/local/php/bin/php
之后出现登陆画面,用户名和密码都是admin,输入后会让你输入新密码。
进去后选择console-->settings-->genernal,在里面找到RRDTool Utility Version 选择 RRDTool 1.3.x
现在还看不到图,需要先设定个计时器
安装vixie-cron-4.1-76.e15.i386.rpm
# crontab -u cactiuser -e //添加如下这句,作用是5分钟更新一次数据
*/1 * * * * /usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php > /dev/null 2>&1
保存退出
# su cactiuser
# /usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php
现在应该有图了
# /etc/init.d/crond start //启动计时器
等几分钟,应该就有数据了。
不得不说,用rrdtools画图比MRTG要漂亮多。而且template资源非常全,可以去CACTI的论坛上去找,应有尽有。接下来要做的就是把nagios也加进来,终归CACTI的报警功能还是比较弱的。 |