centos 安装cacti监控
CentOS 6下Cacti搭建文档
安装依赖关系
yum -y install mysql-devel httpd php php-pdo php-snmp php-mysql lm_sensors net-snmp net-snmp-utils net-snmp-libs rrdtool rrdtool-devel perl-PlRPC perl-DBI perl-rrdtool perl-DBD-MySQL
http配置
alias /cacti /home/op/cacti/
<Directory /home/op/cacti/>
Options Indexes
AllowOverride AuthConfig Options
Order allow,deny
Allow from all
</Directory>
1.安装需要的库文件
yum -y install zlib freetype libjpeg fontconfig gd libxml2 php-gd http
-
安装RRDTool
yum -y install rrdtool
-
安装snmp支持工具
yum -y install net-snmp net-snmp-utils
启动snmpd服务并且加入启动列表
service snmpd start
chkconfig snmpd on
4.安装cacti
下载
wget http://www.cacti.net/downloads/cacti-0.8.8h.tar.gz
配置
解压并放到/home/op
tar xzf cacti-0.8.8h.tar.gz
mv cacti-0.8.8h cacti
(注:最好重命名cacti-0.8.8h文件夹为cacti 便于访问。)
编辑CentOS cacti配置文件,连接MySQL服务的用户名,密码,端口等。
cd /home/op
vi cacti/include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "192.168.100.52";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306″;
添加计划任务(使cacti每5分钟获得一次数据)
添加一个cacti的用户并添加cron任务:
useradd cacti
su cacti
crontab -e
*/5 * * * * /usr/bin/php /home/op/cacti/poller.php > /dev/null 2>&1
更改属组
把cacti网站目录所属组改为cacti
su root
chgrp -R cacti /home/op/cacti
chown -R cacti /home/op/cacti/rra
chown -R cacti /home/op/cacti/log
chown -R cacti /home/op/cacti/poller.php
5 数据库配置
登录
/home/xiaohe/mysql/bin/mysql -uroot -p
重启命令
/home/xiaohe/superctl restart mysql
创建cacti数据库
msyql>create database cacti;
导入cacti.sql
/home/xiaohe/mysql/bin/mysql -uroot -p cacti < /home/op/cacti/cacti.sql
有密码的输入密码,没密码的直接回车
应用
mysql> use cacti
授权
mysql> grant all on cacti.* to cacti@localhost identified by 'cacti';
grant select,insert,update,delete on cacti.* to cacti@192.168.100.52 identified by 'cacti' with grant option;
刷新
mysql> flush privileges;
mysql> exit
snmp 配置
com2sec notConfigUser 192.168.100.52 public
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
access notConfigGroup "" any noauth exact mib2 none none
view all included .1 80
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
syslocation 天上人间 (edit /etc/snmp/snmpd.conf)
syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
dontLogTCPWrappersConnects yes
记得重启snmp和httpd
WEB登陆cacti
http://ip/cacti
(这里如果出现"403 forbidden"的错误,请把selinux关闭)
(cacti 默认密码无法登陆 cd /var/lib/php/ chmod 777 session/)
打开网页—>next—>选择new install,使用一路回车法.完成的用户名为: admin 密码为: admin (初次登陆成功会提示更改密码)
监控客户端配置
yum -y install net-snmp
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak
/etc/init.d/snmpd restart
服务端
将服务端的配置文件拷贝到客户端
scp /etc/snmp/snmpd.conf root@192.168.100.63:/etc/snmp/
测试是否成功
nc -vuz 192.168.100.55 161
chkconfig snmpd on
/etc/init.d/snmpd restart
赵客缦胡缨,吴钩霜雪明。
银鞍照白马,飒沓如流星。