centos6.5系统cacti监控部署文档
系统要求:本文中的Linux操作系统为CentOS 6.5,以下操作均以root执行.
环境描述:
操作系统 ip 监控类别 软件
CentOs 6.5 监控ip 监控端 lnmp环境,cacti,snmp服务,rrdtool
CentOs 6.5 * 被监控端 snmp服务
注:lnmp环境和snmp服务安装不再赘述,按照要求主要是为监控流量,未安装其他插件
监控端操作
1.首先用系统自带的yum命令安装、升级所需的程序库
yum install rrdtool rrdtool-develnet-snmp-devel net-snmp-utils net-snmp-python net-snmp-perl lm_sensors-develfile-devel rpm-devel intltool libart_lgpl elfutils mysql-devel Mod_auth_mysql php-mysql cairodejavu-fonts-common.noarch dejavu-lgc-sans-mono-fonts.noarchdejavu-sans-mono-fonts.noarch fontpackages-filesystem.noarch libXft libXrenderlibthai pango perl-rrdtooltcp_wrappers-devel
2.将snmp服务加入启动项,并开启snmp服务
chkconfig snmpd on
sed -i "41s#default#监控ip#g" /etc/snmp/snmpd.conf
sed -i "62s#systemview#all#g" /etc/snmp/snmpd.conf
sed -i "85s/#//g" /etc/snmp/snmpd.conf
service snmpd start
3.防火墙设置
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 161 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 514 -j ACCEPT
service iptables restart(重启防火墙服务)
4.cacti软件包下载:(路径:/usr/local/src)
wget http://www.cacti.net/downloads/cacti-0.8.8c.tar.gz
解压cacti-0.8.8c.tar.gz并放到nginx默认目录
tar zxvf cacti-0.8.8c.tar.gz
mv cacti-0.8.8c cacti
cp -r cacti /usr/local/nginx/html/
chown -R www:www/usr/local/nginx/html/cacti/
chmod 777 /usr/local/nginx/html/cacti/
useradd cactiuser
chown -R cactiuser:cactiuser/usr/local/nginx/html/cacti/rra
chown -R cactiuser:cactiuser/usr/local/nginx/html/cacti/log
5.Mysql设置
mysql �Cu root �Cp输入密码
mysql> create database cacti defaultcharacter set utf8;
mysql> grant all on cacti.* tocactiuser@localhost identified by 'cactiuser';
mysql> use cacti;
mysql> source/usr/local/nginx/html/cacti/cacti.sql;
mysql> flush privileges;
mysql> quit
备注:为了不修改配置文件,因此使用cactiuser用户,cactiuser密码
6.访问地址,浏览器中输入:http://监控ip/cacti/install
默认密码为admin:admin
首次登陆修改密码
7.加入开机启动项:
crontab -e
*/5 * * * * /usr/local/php/bin/php /usr/local/nginx/html/cacti/poller.php &> /dev/null
service crond restart #启动crond
/usr/local/php/bin/php /usr/local/nginx/html/cacti/poller.php #手动刷新数据
被监控端操作
安装snmp服务
yum -y install net-snmp*
设置防火墙通过snmp服务161端口
sed -i '10 i\-A INPUT -m state --state NEW-m udp -p udp --dport 161 -j ACCEPT' /etc/sysconfig/iptables
service iptables restart(重启防火墙服务)
sed -i "41s#default#监控ip#g" /etc/snmp/snmpd.conf
sed -i "62s#systemview#all#g" /etc/snmp/snmpd.conf
sed -i "85s/#//g" /etc/snmp/snmpd.conf
service snmpd restart(重启snmp服务)
仙人掌中添加各主机
全文完………