534242 发表于 2016-7-5 09:03:55

cacti 安装

   配置服务端      说明:cacti 需要 apache 和 php 的支持,在这里我们用到的是 yum 安装的 lamp 环境。
    (1)安装 epel

1
# yum install -y epel-release




    (2)安装 lamp

1
# yum install -y httpd php php-mysql mysql mysql-server mysql-devel php-gd libjpeg libjpeg-devel libpng-devel




    (3)安装 cacti

1
# yum install -y cacti net-snmp net-snmp-utils rrdtool




    (4)启动服务

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






   (5)编辑 httpd.conf

1
# vim /etc/httpd/conf.d/cacti.conf




       把“Deny from all”改成“Allow from all”
       重启服务

1
# /etc/init.d/httpd restart




   (6)导入数据创建 cacti 库

1
# mysql -uroot -e "create database cacti"




         创建 cacti 用户

1
# mysql -uroot -e "grant all on cacti.* to 'cacti'@'127.0.0.1' identified by 'cacti';"




         导入 sql 文件

1
# mysql -uroot cacti < /usr/share/doc/cacti-0.8.8h/cacti.sql




   (7)编辑 cacti 配置文件

1
# vim /usr/share/cacti/include/config.php




       更改:

1
2
3
4
5
6
7
$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配置


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




      出现如下界面:

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

       进入如下界面:

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

1
# /usr/bin/php /usr/share/cacti/poller.php




          添加 cron 任务

1
2
# crontab -e
*/5 * * * * /usr/bin/php /usr/share/cacti/poller.php




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


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

1
# yum install -y net-snmp




   (11)修改 snmpd.conf

1
# vim /etc/snmp/snmpd.conf




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

1
2
syslocation 56.128
syscontact Root test@test.com




    去掉注释符

1
2
accessnotConfigGroup ""      any       noauth    exactroview rwview none
view all    included.1                               80




   (12)启动 snmp

1
2
# /etc/init.d/snmpd start
正在启动 snmpd:                                           [确定]





页: [1]
查看完整版本: cacti 安装