1.最小化系统安装,并作好系统优化
2.安装所依赖包
- yum 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 openssl openssl-devel perl mysql-devel pango-devel libtool
3.安装mysql
- #rm -fr /etc/ld.so.conf.d/mysql*
-
#tar -zxvf mysql-5.0.87.tar.gz
-
#cd mysql-5.0.87
-
#groupadd mysql
-
#useradd -g mysql mysql
-
#./configure --prefix=/usr/local/cacti/mysql --enable-local-infile --with-charset-gbk --with-extra-charsets=all --with-low-memory --with-mysqld-user=mysql --enable-thread-safe-client
-
#make && make install
- #mv /etc/my.cnf /etc/my.cnf.bak
-
#cp support-files/my-medium.cnf /etc/my.cnf
-
#cd /usr/local/cacti/mysql/
-
#chown -R mysql:mysql .
-
#./bin/mysql_install_db --user=mysql
-
#chown -R root .
-
#chown -R mysql var
-
#./bin/mysqld_safe --user=mysql &
#echo "/usr/local/cacti/mysql/lib/mysql" >> /etc/ld.so.conf
#rm -fr /etc/init.d/mysqld
#cp /opt/cacti/mysql-5.0.87/support-files/mysql.server /etc/init.d/mysqld
#ln -s /usr/local/cacti/mysql/bin/mysql /usr/local/bin/mysql
#ldconfig -v
#ldconfig -v | grep mysql
#chmod 755 /etc/init.d/mysqld
#chkconfig --add mysqld
#chkconfig mysqld on
4.安装apache
- #tar zxvf httpd-2.2.21.tar.gz
-
#cd httpd-2.2.21
-
#./configure --prefix=/usr/local/cacti/apache --enable-so --enable-rewrite --enable-ssl --with-ssl=/usr/bin/openssl --with-zlib --enable-mods-shared=all --enable-track-vars --with-mysql=/usr/local/cacti/mysql
-
#make
-
#make install
-
#/usr/local/cacti/apache/bin/apachectl start
-
#ln -s /usr/local/cacti/apache/bin/apachectl /etc/init.d/httpd
-
#vi /etc/init.d/httpd
#chkconfig: 235 98 98 #description:http server
chkconfig --add httpd
chkconfig httpd on-
#chkconfig --add httpd
-
#vi /usr/local/cacti/apache/conf/httpd.conf #支持php
- AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html
如果启动出现错误:
httpd: apr_sockaddr_info_get() failed for bogon
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
只要hostname localhost即可
5.安装php
- #tar zxvf php-5.2.8.tar.gz
-
#cd php-5.2.8
-
#./configure --prefix=/usr/local/cacti/php --with-config-file-path=/usr/local/cacti/php --with-apxs2=/usr/local/cacti/apache/bin/apxs --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/cacti/mysql/ --with-mysqli=/usr/local/cacti/mysql/bin/mysql_config --with-gd --with-libxml-dir --with-jpeg-dir --enable-sockets --enable-fastcgi
-
#make
-
#make test
-
#make install
-
#cp php.ini-dist /usr/local/cacti/php/php.ini
-
#ln -s /usr/local/cacti/php/bin/php /usr/bin/
写一个phpinfo 放在/usr/local/cacti/apache/htdocs
然后重启apache
[root@bogon modules]# /usr/local/cacti/apache/bin/apachectl restart
如果提示错误:
/usr/local/cacti/apache/bin/apachectl restart
httpd: Syntax error on line 106 of /usr/local/cacti/apache/conf/httpd.conf: Cannot load /usr/local/cacti/apache/modules/libphp5.so into server: /usr/local/cacti/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
那么需要关闭selinux
setenforce 0
6.安装rrdtool
- #tar -zxvf rrdtool-1.3.9.tar.gz
-
#cd rrdtool-1.3.9
-
#./configure --prefix=/usr/local/cacti/rrdtool
-
#make
-
#make install
7.安装snmp
yum安装(成功)
- #yum install net-snmp
-
#yum install net-snmp-*
编译安装(未成功,可能是没删除原来的snmp)
- #tar -zxvf net-snmp-5.4.2.1.tar.gz
-
#cd net-snmp-5.4.2.1
-
#./configure --prefix=/usr/local/cacti/snmp
-
#make
-
#make install
-
#ln -s /usr/local/cacti/snmp/bin/* /usr/local/bin/
-
#cp EXAMPLE.conf /usr/local/cacti/snmp/share/snmp/snmpd.conf
-
#echo "/usr/local/cacti/snmp/sbin/snmpd" >> /etc/rc.local
切换下用户看下变量
8.安装spine
- #tar zxvf cacti-spine-0.8.7h.tar.gz
- #cd cacti-spine-0.8.7h
-
#./configure --prefix=/usr/local/cacti/spine
- --with-snmp=/usr/local/cacti/snmp/如果编译安装的snmp加上此参数
-
#make
-
#make isntall
看下spine的信息
cat /usr/local/cacti/spine/etc/spine.conf.dist
- DB_Host localhost
-
DB_Database cacti
-
DB_User cactiuser
-
DB_Pass cactiuser
-
DB_Port 3306
-
DB_PreG 0
9.创建cacti的数据库
- #groupadd cactiuser
-
#useradd cacti -g cactiuser
-
#/usr/local/bin/mysql
-
mysql> create database cacti;
-
Query OK, 1 row affected (0.02 sec)
-
-
mysql> grant all privileges on cacti.* to cactiuser@localhost identified by "cactiuser";
-
Query OK, 0 rows affected (0.04 sec)
10.安装cacti
- #tar zxvf cacti-0.8.7h.tar.gz
-
#mv cacti-0.8.7h /usr/local/cacti/apache/htdocs/cacti
- #cat /usr/local/cacti/apache/htdocs/cacti/include/config.php
- $database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactiuser";
$database_port = "3306";
$database_ssl = false;
添加cacti数据库
- #cd /usr/local/cacti/apache/htdocs/cacti
- #/usr/local/bin/mysql cacti < cacti.sql
自动执行任务
- #crontab -u cacti -e
- */5 * * * * /usr/local/cacti/php/bin/php -q /usr/local/cacti/apache/htdocs/cacti/poller.php > /var/log/poller.log 2>&1
- #touch /var/log/poller.log
- #chown cacti:cactiuser /var/log/poller.log
#vi /usr/local/cacti/apache/htdocs/cacti/poller.php
fwrite(fopen("/home/cacti/php.txt","w"),date("Y-m-d H:i:s"));
放在 ?> 前面
在crontab中不要添加用户,否则会报错
- # cd /usr/local/cacti/apache/htdocs/cacti/
- # chmod 755 poller.php cmd.php
- #chown -R cacti:cactiuser /usr/local/cacti/apache/htdocs/cacti/
- #/usr/local/cacti/php/bin/php /usr/local/cacti/apache/htdocs/cacti/poller.php
如果在poller.log出现POLLER: Poller[0] WARNING: Cron is out of sync with the Poller Interval! The Poller Interval is '300' seconds, with a maximum of a '300' second Cron, but 515 seconds have passed since the last poll
为添加
11.安装plugin
- #tar zxvf cacti-plugin-0.8.7h-PA-v3.0.tar.gz
-
#cd cacti-plugin-arch/
-
#/usr/local/bin/mysql cacti < pa.sql
-
#cp cacti-plugin-0.8.7h-PA-v3.0.diff /usr/local/cacti/apache/htdocs/cacti/
-
#cd /usr/local/cacti/apache/htdocs/cacti/
-
#patch -p1 -N < cacti-plugin-0.8.7h-PA-v3.0.diff
-
- #vi /usr/local/cacti/apache/htdocs/cacti/include/global.php
-
注释####$config['url_path']=$url_path; -- 修改为--> $config['url_path']='/cacti/';
12.安装setting
- #tar zxvf settings-v0.71-1.tgz
-
#mv settings /usr/local/cacti/apache/htdocs/cacti/plugins/
13.安装weathermap
- #unzip php-weathermap-0.97a.zip
-
#mv weathermap/ /usr/local/cacti/apache/htdocs/cacti/plugins/
-
#cd /usr/local/cacti/apache/htdocs/cacti/plugins/weathermap/
-
#chown cacti output/
-
#cp editor-config.php-dist editor-config.php
-
#chown daemon configs/
-
#chmod u+w configs/
- #vi editor-config.php修改下面
- $cacti_base = "/usr/local/cacti/apache/htdocs/cacti";
- $cacti_url = "";
- $mapdir= $cacti_base.'/plugins/weathermap/configs';
- $ignore_cacti = FALSE; #如果为FALSE则不需要修改
- #vi editor.php
- $ENABLED=false; 改成 $ENABLED=true;
14.安装monitor
- #tar zxvf monitor-latest.tgz
-
#mv monitor /usr/local/cacti/apache/htdocs/cacti/plugins/
15.安装thold
- #tar zxvf thold-v0.4.9-3.tgz
-
#mv thold /usr/local/cacti/apache/htdocs/cacti/plugins/
16.安装ntop
- #tar zxvf libpcap-1.1.1.tar.gz
-
#cd libpcap-1.1.1
-
#./configure
-
#make
-
#make install
如果出现
configure: error: Your operating system's lex is insufficient to compile
libpcap. flex is a lex replacement that has many advantages, including
being able to compile libpcap. For more information, see
.
configure: WARNING: don't have both flex and bison; reverting to lex/yacc
输入即可
- #yum install GeoIP-* (否则会报错)
- #tar zxvf ntop-4.1.0.tar.gz
- #cd ntop-4.1.0
-
#./autogen.sh --with-rrd-home=/usr/local/cacti/rrdtool --disable-snmp
-
#./configure --prefix=/usr/local/ntop --with-rrd-home=/usr/local/cacti/rrdtool --disable-snmp
-
#make
-
#make install
如果出现错误
ERROR: gdbm header or library routines are missing
- yum install gdbm gdbm-devel
配置ntop
- #groupadd ntop
-
#useradd ntop -g ntop
-
#mkdir /var/log/ntop
-
#cp packages/RedHat/ntop.conf.sample /etc/ntop.conf
-
#chown -R ntop.ntop /usr/local/ntop/share/ntop/
-
#chown -R ntop.ntop /var/log/ntop/
- #ln -s /usr/local/lib/libpcap.so.1.1.1 /lib/libpcap.so.1
- #ldconfig
- #/usr/local/ntop/bin/ntop -A #设定密码
- #/usr/local/ntop/bin/ntop -p /var/log/ntop启动ntop 错误如下
- Wed Nov 23 11:46:02 2011 **ERROR** RRD: Disabled - unable to create base directory (err 13, /usr/local/ntop/var/ntop/rrd)
因为缺少数据存储路径,执行
- #mkdir /usr/local/ntop/var/ntop/rrd
-
#chmod -R 777 /usr/local/ntop/var/ntop/rrd/
- #tar zxvf ntop-v0.2-1.tgz
-
#mv ntop /usr/local/cacti/apache/htdocs/cacti/plugins
-
注意这是两个包
17.安装syslog
- #tar zxvf syslog-v1.22-1.tgz
-
#mv syslog /usr/local/cacti/apache/htdocs/cacti/plugins/
建立syslog数据库
- #/usr/local/bin/mysql
-
mysql> create database syslog;
导入syslog表
- #/usr/local/bin/mysql syslog < /usr/local/cacti/apache/htdocs/cacti/plugins/syslog/syslog.sql
给权限
- # /usr/local/bin/mysql
-
mysql> grant all privileges on syslog.* to cactiuser@localhost identified by "cactiuser";
-
Query OK, 0 rows affected (0.02 sec)
-
-
mysql> flush privileges;
-
Query OK, 0 rows affected (0.03 sec)
安装syslog-ng
配置syslog-ng
- #vi /etc/syslog-ng/syslog-ng.conf #在最低下添加
-
source net {
-
udp();
-
};
-
destination d_mysql {
-
pipe("/tmp/mysql.pipe"
-
template("INSERT INTO syslog_incoming (host,facility,priority,date,time,massage)
-
VALUES ('$HOST','$FACILITY','$PRIORITY', '$YEAR-$MONTH-$DAY', '$HOUR:$MIN:$SEC', '$MSG' );\n")
-
template-escape(yes)
-
);
-
};
-
log { source(net); destination(d_mysql); };
-
log { source(s_sys); destination(d_mysql); };
创建syslogtomysql
- #vi /sbin/syslogtomysql
-
#!/bin/bash
-
if [ ! -e /tmp/mysql.pipe ]; then
-
mkfifo /tmp/mysql.pipe
-
fi
-
while [ -e /tmp/mysql.pipe ]
-
do
-
mysql -u cactiuser --password=cactiuser syslog < /tmp/mysql.pipe
- done
- #chmod 755 /sbin/syslogtomysql
-
# echo "/sbin/syslogtomysql &" >> /etc/rc.local
-
# /sbin/syslogtomysql &
- #ps aux|grep mysqld
-
#kill掉mysql
-
#service mysqld start
-
#service syslog-ng start
如果syslog-ng启动提示错误这个是属于mysql的错误,重新加一遍上面syslog的权限试下
ERROR 1054 (42S22) at line 1: Unknown column 'massage' in 'field list'
重新
添加随机启动
- # chkconfig syslog off
-
# chkconfig --del syslog
-
# chkconfig syslog-ng on
-
# chkconfig --add syslog-ng
18.安装discovery
- #tar zxvf discovery-v1.3-1.tgz
-
#mv discovery /usr/local/cacti/apache/htdocs/cacti/plugins/discover
19.修改snmp.comf
- #vi /etc/snmp/snmpd.conf
- com2sec notConfigUser 127.0.0.1 public #允许的IP
com2sec notConfigUser 192.168.10.223 public
- com2sec notConfigUser default public--->com2sec notConfigUser your_snmpd_server_ip public
- #view all included .1 80---->view all included .1 80
-
-
access notConfigGroup "" any noauth exact systemview none none-->
-
access notConfigGroup "" any noauth exact all none none
20.打开161端口,并重启防火墙
- # vi /etc/sysconfig/iptables
-
-A INPUT -p tcp -m tcp --dport 161 -j ACCEPT
-
# service iptables restart
-
Flushing firewall rules: [ OK ]
-
Setting chains to policy ACCEPT: filter [ OK ]
-
Unloading iptables modules: [ OK ]
-
Applying iptables firewall rules: [ OK ]
-
Loading additional iptables modules: ip_conntrack_netbios_n[ OK ]
21.打开浏览器输入地址 下一步,下一步
修改rrdtool地址为:/usr/local/cacti/rrdtool/bin/rrdtool
点击User Management
点击admin
勾选Plugin Management 并save
选择Settings
选择paths标签页,补全命令路径
/usr/local/cacti/rrdtool/bin/rrdtool
/usr/local/cacti/apache/htdocs/cacti/poller.php
保存
点击Deeices,右上角选择ADD
写上一个名字,添加上ip地址,模板类型选择ucd/net Snmp Host,version2,然后点击Create
观察snmp无错误
添加SNMP-Get Mounted Patitions ,然后点击右上角的
再有边可以选择需要监控的项目 打勾 然后添加
左边选择Graph Trees ,然后选贼Default Tree 添加图
add添加
如图选择刚才添加的IP 点击保存
图像出来了
过一会数据也出来了
阅读(9960) | 评论(0) | 转发(3) |