Cacti简介
Cacti是一套基于php、mysql、SNMP、RRDTool开发的网络流量监测图形分析工具。Cacti通过snmpget获取数据,使用RRDTool绘画图形。最后通过web方式呈现出来
Cacti三层架构:
数据采集层:通过SNMP或自定义脚本进行数据采集
数据存储层:通过cacti模板等数据存放至MYSQL中
数据展现层:通过WEB方式呈现出来
一、安装
1、安装必须的软件包
yum -y install httpdphp php-mysql php-ldap php-xml net-snmp-utils mysql mysql-server net-snmplm_sensors gcc gcc-c++ libart_lgpl-devel zlib-devel libpng-devel freetype-devel
2、安装rrdtool。Rrdtool是一个绘图工具,系统光盘中没有提供,所以需要手工安装
(1)安装rrdtool编译时所需软件
tar xvf rrdtool-1.2.27.tar.gz
cd rrdtool-1.2.27
./configure –prefix=/usr/local/
make && make install
编译安装完成后我们启动mysql-httpd服务
[root@cacti rrdtool-1.2.27]# /etc/init.d/httpd start
正在启动 httpd:httpd: Could not reliably determine the server’s fully qualified domain name, using cacti.yk for ServerName [确定]
[root@cacti rrdtool-1.2.27]# /etc/init.d/mysqld start
初始化 MySQL 数据库: Installing MySQL system tables…
OK
Filling help tables…
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password ‘new-password’
/usr/bin/mysqladmin -u root -h cacti.yk password ‘new-password’
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[确定]
正在启动 mysqld: [确定]
随后我们写入一个测试页,确保LAMP平台工作正常。
[root@cacti ~]# cat /var/www/html/yankai.php
<?php
phpinfo();
?>
我们访问测试页http://IP/yankai.php如下:
3.接下来安装cacti
1)cacti本质上是一个PHP网站,只需要把它解压并拷贝到/var/www/html/目录下即可
[root@cacti cacti]# tar zxf cacti-0.8.7g.tar.gz
[root@cacti cacti]# mv cacti-0.8.7g /var/www/html/cacti
[root@cacti cacti]# cd /var/www/html/cacti/
[root@cacti cacti]# ls
2)创建cactiuser用户,并设置相关目录的属主、属组
[root@cacti cacti]# useradd cactiuser
[root@cacti cacti]# chown -R cactiuser.cactiuser rra/ log/
其中rra目录是收集到的监控数据目录,log目录是日志目录
3)接下来我们创建一个数据库
为数据库进行授权:
[root@cacti ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.71 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> create database cactidb default character set utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on cactidb.* to ‘cactiuser’@’localhost’ identified by ‘cacti’;
Query OK, 0 rows affected (0.00 sec)
4)以cactiuser的身份把sql脚本导入到数据库
[root@cacti cacti]# pwd
/var/www/html/cacti
[root@cacti cacti]# mysql -ucactiuser -pcacti cactidb < cacti.sql
5)修改相关的php文件,以便于apache通过php连接mysql数据库时,可以提供正确的用户名、密码等。
[root@cacti cacti]# pwd
/var/www/html/cacti
[root@cacti cacti]# vim include/config.php
修改完成后,最后我们打开浏览器输入http://IP/cacti/install出现引导界面如下:
用户名密码这里默认是admin&admin
如果是第一次它会提示必须更改密码。
之后我们进入cacti监控平台的界面
cacti下载链接:https://pan.baidu.com/s/15DYhjLZxy6Tm8TWHHcW5Dg 密码:9lps