需要的软件:
MySQL、php、apache、rrdtool、snmp、cacti
安装步骤:
1安装mysql数据库
[root@test usr]# groupadd mysql
[root@test usr]# useradd -g mysql mysql
[root@test usr]# cd /usr/local
[root@test local]# tar zxvf mysql-5.1.41.tar.gz
[root@test local]# mv mysql-5.1.41 mysql
[root@test mysql]# cd mysql
[root@test mysql]# ./configure –prefix=/usr/local/mysql
[root@test mysql]# make && make install
[root@test mysql]# /usr/local/mysql/bin/mysql_install_db –user=mysql
[root@test mysql]# chown -R root .
[root@test mysql]# chown -R mysql data
[root@test mysql]# chgrp -R mysql .
[root@test mysql]# ./bin/mysqld_safe –user=mysql &
[root@test mysql]# /usr/local/mysql/bin/mysqld_safe –user=mysql &
2安装apache服务
[root@test usr]# tar -zxvf httpd-2.2.14.tar.gz
[root@test usr]# cd httpd-2.2.14
[root@test httpd-2.2.14]# ./configure –prefix=/www –enable-so
[root@test httpd-2.2.14]# make && make install
[root@test httpd-2.2.14]# cp /www/bin/apachectl /etc/init.d/httpd
[root@test httpd-2.2.14]# cd /etc/rc3.d
[root@test rc3.d]# ln -s /etc/init.d/httpd S85httpd
[root@test rc3.d]# ln -s /etc/init.d/httpd K85httpd
[root@test rc3.d]# /www/bin/apachectl start
Apache 安装完毕
3安装PHP
[root@test usr]# tar -zxvf php-5.2.12.tar.gz
[root@test usr]# cd php-5.2.12
[root@test php-5.2.12]# ./configure –prefix=/www/php \
> –with-apxs2=/www/bin/apxs \
> –with-config-file-path=/www/php \
> –enable-sockets \
> –with-mysql=/usr/local/mysql \
> –with-zlib-dir=/usr/include \
> –with-gd
[root@test php-5.2.12]# make && make install
[root@test php-5.2.12]# cp php.ini-dist /www/php/php.ini
[root@test php-5.2.12]# vi /www/conf/httpd.conf
按 I 键 添加 AddType application/x-tar .tgz
AddType application/x-httpd-php .php
AddType image/x-icon .ico
DirectoryIndex index.php index.html index.html.var
保存退出 :wq
[root@test php-5.2.12]# /www/bin/apachectl restart
Php安装完毕
4安装rrdtool
[root@test usr]# tar zxvf rrdtool-1.3.8.tar.gz
[root@test usr]# cd rrdtool-1.3.8
[root@test rrdtool-1.3.8]# ./configure
[root@test rrdtool-1.3.8]# make && make install
Rrdtool安装完毕
5安装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 四个安装包,可以在系统盘中找到相应的RPM包进行安装,也可以用yum install net-snmp*进行安装。
安装完成后修改配置文件:
[root@test usr]# vi /etc/snmp/snmpd.conf
更改 1、com2sec notConfigUser default public
改为:com2sec notConfigUser 127.0.0.1 public
2、access notConfigGroup “” any noauth exact systemview none none
改为:access notConfigGroup “” any noauth exact all none none
3、#view all included .1 80
将前面的 # 注释 去掉。
保存退出 :wq
[root@test usr]# service snmpd restart
6配置MYSQL数据库
mysql> create database cactidb;
mysql> grant SUPER,REPLICATION CLIENT,process on *.* to cactiuser@localhost identified by ‘cactipw’;
7安装/ 配置cacti
[root@test usr]# useradd cactiuser -g users
[root@test usr]# passwd cactiuser (pwd:cactipw)
[root@test usr]# cp cacti-0.8.7b.tar.gz /www/htdocs/
[root@test usr]# cd /www/htdocs/
[root@test htdocs]# tar zxvf cacti-0.8.7b.tar.gz
[root@test htdocs]# mv cacti-0.8.7b cacti
[root@test htdocs]# cd cacti
[root@test cacti]# /usr/local/mysql/bin/mysql -u root -pmysql cactidb < cacti.sql
[root@test cacti]# chown -R cactiuser rra/ log/
[root@test cacti]# cd scripts
[root@test scripts]# chown cactiuser:users *
[root@test scripts]# vi /www/htdocs/cacti/include/config.php
$database_type = “mysql”;
$database_default = “cactidb”;
$database_hostname = “localhost”;
$database_username = “cactiuser”;
$database_password = “cactipw”;
更改用户、密码 等项 与上面给出的对应 保存退出
[root@test scripts]# crontab -u cactiuser -e
加入
*/5 * * * * /www/php/bin/php /www/htdocs/cacti/poller.php > /dev/null 2>&1
保存退出:wq
全部设置完毕。
打开浏览器 http://localhost/cacti 进入cacti的初始设置页面
第一次默认登陆账号:admin 密码 admin J
登陆后在新改个密码就OK
需要说明的还有路径
snmpwalk Binary Path : /usr/bin/snmpwalk
snmpget Binary Path: /usr/bin/snmpget
RRDTool Binary Path: /usr/rrdtool-1.3.8/src/rrdtool
PHP Binary Path: /www/php/bin/php
Cacti Log File Path: /www/htdocs/cacti/log/cacti.log
Cactid Poller File Path: /www/htdocs/cacti/poller.php
注:此时graphs还不能显示图形,需要将服务重新启动一下
[root@test scripts]# service snmpd restart
[root@test scripts]# service mysql restart
[root@test scripts]# service httpd restart
OK,现在打开http://localhost/cacti进入graphs查看localhost就会有图形了。
要添加自定义图形,请阅读《CACTI使用文档》。
原文章地址Cacti安装配置的详细步骤