前提:已经编译安装好了LAMP(mysql5.5)

一、配置服务端

1、注释中心主机,并启用虚拟主机,添加一个虚拟主机

# cd /etc/httpd/

# vim httpd.conf

注释掉:DocumentRoot "/usr/local/apache/htdocs"

启用:# Virtual hosts

Include /etc/httpd/extra/httpd-vhosts.conf


# vim /etc/httpd/extra/httpd-vhosts.conf

DocumentRoot "/web/vhosts/cacti"

ServerName cacti.fsy.com

Options Indexes

AllowOverride none

Require all granted

 

  ErrorLog "logs/cati-error_log"

  CustomLog "logs/cacti-access_log" common

 

  

2、安装rrdtool采集工具

1)安装rrdtool之前需要安装相应的lib库,如下安装:

# yum install cairo-devel libxml2-devel pango pango-devel –y

2)

# tar xzf rrdtool-1.4.5.tar.gz 

# cd rrdtool-1.4.5 

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

# make && make install   

# /usr/local/rrdtool/bin/rrdtool

此时可以显示rrdtool的版本,表明安装成功!

3)创建链接

# ln -s /usr/local/rrdtool/bin/* /usr/local/bin/


3、安装SNMP服务

# yum install net-snmp net-snmp-utils –y

4、初始化安装cacti

# mkdir -p /web/vhosts 

# tar xf cacti-0.8.8a.tar.gz -C /web/vhosts

# cd /web/vhosts/

# ln -sv cacti-0.8.8a cacti

# service httpd restart


5、初始化数据库并创建用户

# cd cacti

# mysqladmin creat cactidb

# mysql cactidb < cacti.sql

# mysql -e "GRANT ALL ON cactidb.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser'"

# mysqladmin flush-privileges


6、修改cacti的配置文件

# cd include/

# vim config.php

修改以下两项

$database_default = "cactidb";

$url_path = "/";


7、创建执行用户cactiuser,并修改目录属主和属组

# /web/vhosts/cacti

# useradd cactiuser

# chown -R cactiuser:cactiuser rra/ log


8、安装cacti

配置本地域名解析,添加以下内容

202.207.178.6 cacti.fsy.com

然后访问cacti.fsy.com,即可开始安装

因为LAMP是编译安装的,所以在安装cacti时将/usr/local/php/bin/php

默认用户名和密码都是admin

9、为cactiuser定义任务计划,并测试

若没有crontab,需要装vixie-crons crontabs

1)定义任务计划,每五分钟执行一次poller.php

# echo '*/5 * * * * /usr/local/php/bin/php /web/vhosts/cacti/poller.php &>/dev/null' > /var/spool/cron/cactiuser

2)为使任务计划顺利执行,更改时区

# vim /etc/php.ini

修改如下内容:

date.timezone = Asia/Shanghai

3)测试

# su - cactiuser

$ /usr/local/php/bin/php /web/vhosts/cacti/poller.php

二、配置被监控的linux主机

1、修改配置文件

# vim /etc/snmp/snmpd.conf

将62行处改为如下内容,以使所有都可以访问:

access  notConfigGroup ""      any       noauth    exact  all none none

将41行处改为如下内容,以允许服务端采集其数据

com2sec notConfigUser  202.207.178.6       public

启用65行

view all    included  .1                               80

2、启动服务

# servcie snmpd restart

在服务器端操作网页,配置即可


                            欢迎批评指正!