配置服务端  

      说明:cacti 需要 apache 和 php 的支持,在这里我们用到的是 yum 安装的 lamp 环境。

    (1)安装 epel

[[email protected] ~]# yum install -y epel-release

    (2)安装 lamp

[[email protected] ~]# yum install -y httpd php php-mysql mysql mysql-server mysql-devel php-gd libjpeg libjpeg-devel libpng-devel

    (3)安装 cacti

[[email protected] ~]# yum install -y cacti net-snmp net-snmp-utils rrdtool

    (4)启动服务

[[email protected] ~]# /etc/init.d/mysqld start
Please report any problems with the /usr/bin/mysqlbug script!
                                                           [确定]
正在启动 mysqld:                                          [确定]
[[email protected] ~]# /etc/init.d/httpd start
正在启动 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName
                                                           [确定]
[[email protected] ~]# /etc/init.d/snmpd start
正在启动 snmpd:                                           [确定]


     (5)编辑 httpd.conf

[[email protected] ~]# vim /etc/httpd/conf.d/cacti.conf

       把“Deny from all”改成“Allow from all”

       重启服务

[[email protected] ~]# /etc/init.d/httpd restart

     (6)导入数据创建 cacti 库

[[email protected] ~]# mysql -uroot -e "create database cacti"

         创建 cacti 用户

[[email protected] ~]# mysql -uroot -e "grant all on cacti.* to 'cacti'@'127.0.0.1' identified by 'cacti';"

         导入 sql 文件

[[email protected] ~]# mysql -uroot cacti < /usr/share/doc/cacti-0.8.8h/cacti.sql

     (7)编辑 cacti 配置文件

[[email protected] ~]# vim /usr/share/cacti/include/config.php

       更改:

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "127.0.0.1";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
$database_ssl = false;

      (8)web 访问 cacti 并安装

       http://ip/cacti/

       如不能访问,检查iptables和selinux配置

1.1 cacti 安装

      点两下“next”和一次“finish”即可:

1.1 cacti 安装


1.1 cacti 安装


      出现如下界面:

1.1 cacti 安装

      输入 admin admin 登录,重新设置新的密码

1.1 cacti 安装

       进入如下界面:

1.1 cacti 安装

        (9)执行 poller.php,生成图形,加入计划任务

[[email protected] ~]# /usr/bin/php /usr/share/cacti/poller.php

          添加 cron 任务

[[email protected] ~]# crontab -e
*/5 * * * * /usr/bin/php /usr/share/cacti/poller.php

         此时,浏览器界面点击 graphs -> Default Tree -> Host:Localhost ,刷新一下,可看到出图,等一会儿,数据就出来了

1.1 cacti 安装

       那么,刚刚只是监控了本地机器的情况,我们强烈需要监控其他客户端机器,所以下面配置一下客户端

     (10)安装 snmp

[[email protected] ~]# yum install -y net-snmp

     (11)修改 snmpd.conf

[[email protected] ~]# vim /etc/snmp/snmpd.conf

     对 syslocation 以及 syscontact 进行修改,其中 syslocation 可以写本机 ip ,syscontact 写管理员邮箱。

syslocation 56.128
syscontact Root [email protected]

    去掉注释符

access  notConfigGroup ""      any       noauth    exact  roview rwview none
view all    included  .1                               80

     (12)启动 snmp

[[email protected] ~]# /etc/init.d/snmpd start
正在启动 snmpd:                                           [确定]