一、安装epel-release扩展源
[root@www ~]# rpm -ivh epel-release-6-8_32.noarch.rpm
二、安装lamp环境
[root@www ~]# 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
[root@www ~]# yum -y install cacti net-snmp net-snmp-utils rrdtool php-snmp
四、启动服务
[root@www ~]# /etc/init.d/mysqld start [root@www ~]# /etc/init.d/httpd start [root@www ~]# /etc/init.d/snmpd start
五、配置cacti
1、初始化数据库
[root@www ~]# mysql_secure_installation
[root@www ~]# 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>
[root@www ~]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
3、创建cacti数据库
[root@www ~]# mysql -uroot -p -e "create database cacti"
4、创建cacti数据库用户
[root@www ~]# mysql -uroot -p -e "grant all on cacti.* to 'cacti'@'127.0.0.1' identified by 'cacti';"
5、导入数据库文件
[root@www ~]# mysql -uroot -p cacti < /usr/share/doc/cacti-0.8.8b/cacti.sql
6、配置cacti配置文件
[root@www ~]# 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, 生成图形, 并加入计划任务
[root@www ~]# /usr/bin/php /usr/share/cacti/poller.php
date.timezone报错,修改php.ini相关配置
[root@www ~]# vim /etc/php.ini
947 date.timezone = 'Asia/Chongqing'
[root@www ~]# /usr/bin/php /usr/share/cacti/poller.php
[root@www ~]# crontab -e
*/5 * * * * /usr/bin/php /usr/share/cacti/poller.php //每5分钟执行一次
(4)查看cacti生成图形信息
八、cacti添加客户端监控
1、安装net-snmp
[root@sh ~]# yum -y install net-snmp
2、修改snmp-conf
[root@sh ~]# 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
[root@sh ~]# /etc/init.d/snmpd start
3、在服务端添加配置
*Create Graphs for this Host
Graph Trees(添加监控主机)