cacti安装
Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具。它通过snmp来获取数据,使用RRDtool绘画图形
下面开始准备安装:
首先看看gcc有没有安装:
[root@localhost ~]# rpm -qa |grep gcc
gcc44-c++-4.4.0-6.el5
gcc-objc-4.1.2-48.el5
gcc-c++-4.1.2-48.el5
gcc-4.1.2-48.el5
gcc44-4.4.0-6.el5
gcc-gfortran-4.1.2-48.el5
libgcc-4.1.2-48.el5
gcc-gnat-4.1.2-48.el5
gcc44-gfortran-4.4.0-6.el5
//第一:开始安装apache服务:
[root@localhost ~]# tar -zxvf httpd-2.2.6.tar.gz
[root@localhost ~]# cd httpd-2.2.6
[root@localhost httpd-2.2.6]# ./configure --prefix=/usr/local/apache --enable-so
[root@localhost httpd-2.2.6]# make && make install
//启动apache服务
[root@localhost ~]# /usr/local/apache/bin/apachectl start
//把apache服务加入开机启动项
[root@localhost ~]# echo "/usr/local/apache/bin/apachectl start" >>/etc/rc.local
第二,安装mysql
//添加mysql用户组
[root@localhost ~]# groupadd mysql
//添加mysql用户,并添加到mysql用户组中
[root@localhost ~]# useradd -g mysql mysql
[root@localhost ~]# tar -zxvf mysql-5.0.45.tar.gz
[root@localhost ~]# cd mysql-5.0.45
[root@localhost mysql-5.0.45]# ./configure --prefix=/usr/local/mysql
[root@localhost mysql-5.0.45]# make && make install
[root@localhost mysql-5.0.45]# cp support-files/my-medium.cnf /etc/my.cnf
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# ./bin/mysql_install_db --user=mysql
[root@localhost mysql]# chown -R mysql var/
[root@localhost mysql]# ./bin/mysqld_safe --user=mysql &
[root@localhost mysql]# cd /root/mysql-5.0.45
[root@localhost mysql-5.0.45]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql-5.0.45]# chmod 755 /etc/init.d/mysqld
[root@localhost mysql-5.0.45]# chkconfig --level 345 mysqld on
[root@localhost ~]# mysqladmin -uroot password tiger
第三,准备安装PHP
//安装zlib
[root@localhost]# tar -zxvf zlib-1.2.3.tar.gz
[root@localhost]# cd zlib-1.2.3
[root@localhost zlib-1.2.3]# ./configure --prefix=/usr/local/zlib
[root@localhost zlib-1.2.3]# make && make install
//安装libpng
[root@localhost ~]# tar -zxvf libpng-1.2.23.tar.gz
[root@localhost ~]# cd libpng-1.2.23
[root@localhost libpng-1.2.23]# ./configure --prefix=/usr/local/libpng
[root@localhost libpng-1.2.23]# make && make install
//安装freetype
[root@localhost ~]# tar -xvf freetype-2.3.10.tar.bz2
[root@localhost ~]# ls
[root@localhost ~]# cd freetype-2.3.10
[root@localhost freetype-2.3.10]# ls
[root@localhost freetype-2.3.10]# ./configure --prefix=/usr/local/freetype
[root@localhost freetype-2.3.10]# make && make install
[root@localhost freetype-2.3.10]# cd /usr/local/freetype/
//安装jpeg
//用yum安装的jpeg fontconfig gd
//开始安装PHP
[root@localhost]# tar -zxvf php-5.2.5.tar.gz
[root@localhost php-5.2.5]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype --enable-gd-native-ttf --with-ttf --enable-gd-jis-conv --enable-xml --enable-mbstring --enable-sockets
[root@localhost php-5.2.5]# make && make install
在这行下边
LoadModule php5_module modules/libphp5.so
添加
AddType application/x-httpd-php .php
找到DirectoryIddex index.html index.html.var
修改为
DirectoryIndex index.html index.html.var index.php
[root@localhost php-5.2.5]# /usr/local/apache2/bin/apachectl restart
如果出现问题,无法解析PHP文件,将
LoadModule php5_module modules/libphp5.so
下的
AddType application/x-httpd-php .php
注释掉
重新在
AddType application/x-gzip .gz .tgz
下添加这么一行就OK了
AddType application/x-httpd-php .php
第四 ,安装rrdtool
//安装rrdtool必须安装以下安装包,为了方便就直接用yum安装了。
[root@localhost ]# yum install cairo-devel libxm12-devel pango-devel pango libpng-devel freetye freetype-devel libart_lgpl-devel intltool
[root@localhost]# tar -zxvf rrdtool-1.0.49.tar.gz
[root@localhost]# cd rrdtool-1.0.49
[root@localhost rrdtool-1.0.49]# ./configure --prefix=/usr/local/rrdtool -disable-tcl
[root@localhost rrdtool-1.0.49]# make && make install
[root@localhost rrdtool-1.0.49]# ln -s /usr/local/rrdtool/bin/* /usr/local/bin/
第五,开始安装cacti
[root@aca400fe ~]# tar -zxvf cacti-0.8.7i.tar.gz
[root@aca400fe ~]# mv cacti-0.8.7i/* /usr/local/apache/htdocs/
mv: overwrite `/usr/local/apache/htdocs/index.php'? y //由于前期安装lamp的时候新建了个index.php在这就需要覆盖下
[root@aca400fe ~]# useradd cacti
[root@aca400fe ~]# chown -R cacti /usr/local/apache/htdocs/rra
[root@aca400fe ~]# chown -R cacti /usr/local/apache/htdocs/
[root@aca400fe ~]# chgrp -R cacti /usr/local/apache/htdocs/
//登录MySQL,新建数据,并授权
[root@aca400fe ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.45-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database cacti;
Query OK, 1 row affected (0.04 sec)
mysql> grant all on cacti.* to cacti@'localhost' identified by 'cacti';
Query OK, 0 rows affected (0.04 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@aca400fe ~]# cd /usr/local/apache/ho
-bash: cd: /usr/local/apache/ho: No such file or directory
[root@aca400fe ~]# cd /usr/local/apache/htdocs/
[root@aca400fe htdocs]# ls
//导入cacti数据库
[root@aca400fe htdocs]# mysql -uroot -phuye cacti <cacti.sql
[root@aca400fe htdocs]# cd in
include/ index.html index.php install/
[root@aca400fe htdocs]# cd include/
//将/usr/local/apache/htdocs/include/config.php修改成下边这样
[root@aca400fe include]# vi config.php
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
//$database_ssl = false;
/* Default session name - Session name must contain alpha characters */
#$cacti_session_name = "Cacti";
[root@aca400fe include]# cd /usr/local/php/bin/
[root@aca400fe bin]# ls
pear peardev pecl php php-config phpize
被监控的机器上要开启snmp服务
第五,安装net-snmp
[root@localhost ~]# tar -zxvf net-snmp-5.7.1.tar.gz
[root@localhost ~]# cd net-snmp-5.7.1
[root@localhost net-snmp-5.7.1]# ./configure --prefix=/usr/local/net-snmp --enable-developer
[root@localhost net-snmp-5.7.1]# make && make install
[root@localhost net-snmp-5.7.1]# cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmp.conf
[root@aca400fe snmp]# ln -s /usr/local/net-snmp/bin/* /usr/local/bin/
[root@aca400fe snmp]# /usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmp.conf
用主机以下面方式登陆:
//IP/install

浙公网安备 33010602011771号