cacti安装配置文档
生产环境:操作系统:CentOS6.6
任务:监控服务器上安装cacti,配置被监控服务器。
我们要理解监控端(监控服务器),被监控端(客户端)。监控服务器需要安装的软件(包括:net-snmp、libart_lgpl、rrdtool、apache、mysql、php、cacti),被监控端(snmp)。
一、Linux监控服务器上安装Cacti生产环境:CentOS 6.6说明:因生产环境操作系统会最小化安装,在安装软件的时候,请把相关基础软件包安装,否则在安装的过程会报错。例如:yum install gcc glibc glibc-common cairo pango zlib zlib-devel freetypefreetype-devel gd gd-devel-y
1. 安装net-snmp及配置:(1)安装net-snmp#yum install net-snmp*-y
# cp/etc/snmp/snmpd.conf/etc/snmp/snmpd.conf.ori
#cat>/etc/snmp/snmpd.conf<<EOF#把以下内容写入snmpd.conf文件,并会清空snmpd.conf源有内容。
com2sec local localhost public
com2secmynetwork 117.40.239.9 public #定义共同体名
group MyRWGroupv1 local #定义组名
group MyRWGroupv2c local
group MyRWGroupusm local
group MyROGroupv1 mynetwork
group MyROGroupv2c mynetwork
group MyROGroupusm mynetwork
view all included .1 80
access MyROGroup"" anynoauthexactall nonenone
access MyRWGroup""anynoauth exactallall none
syslocationbbs.jxatei.net
syscontact Me<553752017@qq.com>#邮箱
proc mountd
proc ntalkd 4
proc sendmail 10 1
proc httpd10 1
exec echotest/bin/echo hello world
execdisk_used_shell/bin/sh /root/current_disk_used.sh
exechttpd_proc /bin/sh /root/current_httpd_proc.sh
disk / 10000
disk /boot 10000
load121414
EOF#不要忘记了结束符
注意:(1)定义好共同体名,在配置windows客户端时,共体同名要一致。(2)com2sec mynetwork117.40.239.9 public #根据实际情况设置IP地址,做为监控访问通信的地址。
(2)启动snmpd服务:#/etc/init.d/snmpd start#方法一正在启动 snmpd:#servicesnmpdstart#方法二正在启动 snmpd:
(3)检查端口及进程是否启动:# lsof-i:161COMMAND PID USERFD TYPEDEVICE SIZE/OFF NODE NAMEsnmpd 29939 root 7uIPv4 4091635 0t0 UDP *:snmp
#netstat-lntup|grep161 #检查端口号udp 0 0 0.0.0.0:161 0.0.0.0:*29939/snmpd
# ps-ef|grep snmpd|grep -v grep#检查进程root 29939 10 09:58 ? 00:00:00 /usr/sbin/snmpd -LS0-6d -Lf/dev/null -p /var/run/snmpd.pid
2. 安装:libart_lgpl-2.3.17#wget
http://ftp.gnome.org/pub/gnome/sources/libart_lgpl/2.3/libart_lgpl-2.3.17.tar.bz2
#wget
http://oss.oetiker.ch/rrdtool/pub/libs/libart_lgpl-2.3.17.tar.gz
[root@sky9896libart_lgpl-2.3.17]#./configure
[root@sky9896libart_lgpl-2.3.17]#make && make install
3. 安装rrrdtool-1.2.30
#wget
http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.30.tar.gz
#tar xf rrdtool-1.2.30.tar.gz
#cd rrdtool-1.2.30
#./configure
#make && make install
#
ls-l /usr/local/rrdtool-1.2.30/bin/rrdtool && ln -s/usr/local/rrdtool-1.2.30/bin/rrdtool
#
ls -l /usr/local/rrdtool-1.2.30/bin/rrdtool &&ln -s /usr/local/rrdtool-1.2.30/bin/rrdtool /usr/local/bin/rrdtool
注意事项:
报错1:
make: *** 错误 2
make: Leaving directory`/home/skyboy/tools/cacti_tools/rrdtool-1.2.30/bindings'
make: *** 错误 1
make: Leaving directory`/home/skyboy/tools/cacti_tools/rrdtool-1.2.30/bindings'
make: *** 错误 1
make: Leaving directory`/home/skyboy/tools/cacti_tools/rrdtool-1.2.30
#yum -y install perl-ExtUtils-MakeMaker
#解决问题
报错2:
configure: error: Please fix the library issues listedabove and try again.
#yum-y install pango*
报错3:
configure: error: Please fix thelibrary issues listed above and try again.
#yum –y install pango-devel*cairo-devel*
4.安装apache、Mysql、PHP
(1) 安装mysqlphp httpd
#yum install mysql* httpd*php* --skip-broken -y
#cd/etc/httpd/conf
#cphttpd.conf httpd.conf.oldboy.ori#sed -i 's#\#ServerName www.example.com:80#ServerName127.0.0.1:80#' /etc/httpd/conf/httpd.conf#做本地解析就不会提示没有解析#sed-i 's#DirectoryIndex index.html index.html.var#DirectoryIndex index.phpindex.html #' /etc/httpd/conf/httpd.conf #修改成'index.php”为默认主页。(2) 启动httpd服务# /etc/init.d/httpdstart正在启动 httpd:(3) 检查端口# lsof -i:80COMMAND PID USERFD TYPEDEVICE SIZE/OFF NODE NAMEhttpd 17871 root 4uIPv6 3224763 0t0 TCP *:http (LISTEN)httpd 17873 apache 4u IPv6 3224763 0t0TCP *:http (LISTEN)httpd 17874 apache 4uIPv63224763 0t0TCP *:http (LISTEN)httpd 17875 apache 4u IPv6 3224763 0t0TCP *:http (LISTEN)httpd 17876 apache 4u IPv6 3224763 0t0TCP *:http (LISTEN)httpd 17877 apache 4u IPv6 3224763 0t0TCP *:http (LISTEN)httpd 17878 apache 4u IPv6 3224763 0t0TCP *:http (LISTEN)httpd 17879 apache 4u IPv6 3224763 0t0TCP *:http (LISTEN)
#netstat -lntup|grep 80tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2804/mysqld
tcp 0 0 ::ffff:127.0.0.1:8005 :::* LISTEN 1811/java
tcp 0 0 :::8009 :::* LISTEN 1811/java
tcp 0 0 :::80 :::* LISTEN 17871/httpd
tcp 0 0 :::8080 :::* LISTEN 1811/java
# ps -ef|grep httpd|grep -v grep
测试主页:# echo -e"<?php \nphpinfo(); \n?>" >/var/www/html/index.php
http://ip地址
(4) 启动Mysql服务#/etc/init.d/mysqld start 正在启动 mysqld: [确定]
# lsof -i:3306 #检查端口COMMAND PIDUSER FDTYPEDEVICE SIZE/OFF NODE NAMEmysqld 2804 mysql 10uIPv4 3272205 0t0 TCP *:mysql (LISTEN)
# ps -ef|grep mysqld|grep -v grep #检查进程
root 2597 10Nov09 ? 00:00:00 /bin/sh/usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock--pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql 280425971Nov09 ? 00:12:13/usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql--plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log--pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
5.安装cacti#对cacti用户授权,然后建立数据库
mysql>GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser';
QueryOK, 0 rows affected (0.00 sec)
mysql>flush privileges;
QueryOK, 0 rows affected (0.00 sec)
mysql>create database cacti;
QueryOK, 1 row affected (0.00 sec)
# wgethttp://www.cacti.net/downloads/cacti-0.8.8a.tar.gz#tar zxf cacti-0.8.8a.tar.gz# mysql –uroot –pcacti <cacti.sql# chown -Rapache rra/ log/# mv../cacti-0.8.8a /var/www/html/cacti# chown -Rapache.apache cacti# chmod 755/var/www/html/cacti/poller.php# echo '*/5 * * **/usr/bin/php/var/www/html/cacti/poller.php>/dev/null 2>&1' >>/var/spool/cron/root
注意事项:
# vi /etc/sysconfig/iptables
-A INPUT -p udp -m state --state NEW -m udp --dport 161 -j ACCEPT #设置161端口通过防火墙
浏览器端(客户端):
http://117.40.239.9/cacti/index.php
二、 Linux被监控服务器(客户端配置)
Linux客户端配置,只要安装net-SNMP软件包。
# yum install net-snmp* -y# cat>/etc/snmp/snmpd.conf<<EOFcom2sec local localhost publiccom2sec mynetwork117.40.239.9 public #监控服务器IP地址group MyRWGroup v1 localgroup MyRWGroup v2c localgroup MyRWGroup usm localgroup MyROGroup v1 mynetworkgroup MyROGroup v2c mynetworkgroup MyROGroup usm mynetworkview all included.1 80access MyROGroup ""any noauth exact all none none access MyRWGroup"" any noauth exactall all none syslocation117.40.239.9syscontact Me <553752017@qq.com> proc mountd proc ntalkd 4 proc sendmail 10 1 proc httpd 10 1 exec echotest /bin/echo hello world exec disk_used_shell /bin/sh /root/current_disk_used.sh exec httpd_proc /bin/sh/root/current_httpd_proc.shdisk / 10000 disk /boot 10000 load 12 14 14 EOF#vi/etc/sysconfig/iptables
-A INPUT -p udp-m state --state NEW -m udp --dport 161-j ACCEPT#在iptables里添加上一条,用来对161端口通过防火墙
三、Windows被监控服务器(客户端配置)
1)、打开“控制面板”-“添加删除程序”-“添加删除组建”在“管理和监视工具”中选中“简单网络管理协议(snmp)”点击“下一步”,开始安装,在安装过程中需要i386文件。(2)、打开“开始”-“程序”-“管理工具”-“服务”,找到“snmpservice”,右键打开“属性”,选择“安全”,在“接受团体名称”处,点“添加”,在“团体名称”处写入你的cacti使用的community,选中“接受来自这些主机的snmp数据包”,默认值为“localhost”,点击“编辑”,将“localhost”改为cacti监控服务器的实际 ip地址。请看下面示意图。 小结cacti安装配置文档,但是还有好多细节没有小结出来,在后续还会整理相关文档。在这里想讲一个学习思路,或者是说学习体会吧。首先,对理论进行大概的了解,特别是cacti的工作原理和流程先了解一下,理解最好,不过没有理解也没有关系,我们在虚拟机上做实验,在实验的过程当中来消化理论。虚拟机上研究的差不多,然后直接在生产服务器上上线。
页:
[1]