一、安装epel-release扩展源
[[email protected] ~]# rpm -ivh epel-release-6-8_32.noarch.rpm
二、安装lamp环境
[[email protected] ~]# yum -y install httpd php php-mysql mysql mysql-server mysql-devel php-gd libjpeg libjpeg-devel libpng libpng-devel
三、安装cacti、net-snmp、rrdtool、php-snmp
[[email protected] ~]# yum -y install cacti net-snmp net-snmp-utils rrdtool php-snmp
四、启动服务
[[email protected] ~]# /etc/init.d/mysqld start
[[email protected] ~]# /etc/init.d/httpd start
[[email protected] ~]# /etc/init.d/snmpd start
五、配置cacti
1、初始化数据库
[[email protected] ~]# mysql_secure_installation
[[email protected] ~]# mysql -uroot -p
2、配置httpd
19 <IfModule !mod_authz_core.c>
20 # httpd 2.2
21 Order deny,allow
22 Allow from all
23 Allow from localhost
24 </IfModule>
[[email protected] ~]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
3、创建cacti数据库
[[email protected] ~]# mysql -uroot -p -e "create database cacti"
4、创建cacti数据库用户
[[email protected] ~]# mysql -uroot -p -e "grant all on cacti.* to ‘cacti‘@‘127.0.0.1‘ identified by ‘cacti‘;"
5、导入数据库文件
[[email protected] ~]# mysql -uroot -p cacti < /usr/share/doc/cacti-0.8.8b/cacti.sql
6、配置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;
7、访问cacti并安装
(1)http://192.168.1.21/cacti/install,Next---->New Install---->Next
(2)保持默认<Finish>,转到登录页面,默认登录名和密码都是admin,输入会提示修改密码
(3)执行poller.php, 生成图形, 并加入计划任务
[[email protected] ~]# /usr/bin/php /usr/share/cacti/poller.php
date.timezone报错,修改php.ini相关配置
[[email protected] ~]# vim /etc/php.ini
947 date.timezone = ‘Asia/Chongqing‘
[[email protected] ~]# /usr/bin/php /usr/share/cacti/poller.php
[[email protected] ~]# crontab -e
*/5 * * * * /usr/bin/php /usr/share/cacti/poller.php //每5分钟执行一次
(4)查看cacti生成图形信息
八、cacti添加客户端监控
1、安装net-snmp
[[email protected] ~]# yum -y install net-snmp
2、修改snmp-conf
[[email protected] ~]# vim /etc/snmp/snmpd.conf
162 syslocation 192.168.1.251
163 syscontact Root [email protected]
55 view systemview included .1.3.6.1.2.1
56 view systemview included .1.3.6.1.2.1.25.1.1
[[email protected] ~]# /etc/init.d/snmpd start
3、在服务端添加配置
*Create
Graphs for this Host
Graph Trees(添加客户主机)