Linux 安装 Master/Node munin-1.4.6 + rrdtool-1.4.5 监控服务运行状态

因为没有看munin/INSTALL 说明,走了一些弯路,所以在安装软件前最好先看一下安装说明:

01 ### Dowlad Softs: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
02 ### Dowlad Softs: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
05  
06 ### decompress
07 [root@hexuweb102 monitor]$ tar zxvf munin-1.4.6.tar.gz
08 ### custom install Perfix
09 [root@hexuweb102 monitor]$ vi munin-1.4.6/Makefile.config
10    #下面可以自定义,我使用的默认
11    #Default: PREFIX   = $(DESTDIR)/opt/munin
12 <span id="more-889"></span>
13 ################################################################
14 ### make munin: Fail
15 ################################################################
16 [root@hexuweb102 munin-1.4.6]$ make

需要安装 Module-Build,注意有一些依赖库需要先安装,否则会遇到下面错误信息:

01 ### Dowlad Softs: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
02 ### Dowlad Softs: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
04 wget http://mirror.teklinks.com/CPAN/authors/id/D/DA/DAGOLDEN/Perl-OSType-1.002.tar.gz
05 wget http://mirror.teklinks.com/CPAN/authors/id/D/DA/DAGOLDEN/Parse-CPAN-Meta-1.4401.tar.gz
06 wget http://mirror.teklinks.com/CPAN/authors/id/D/DA/DAGOLDEN/Module-Metadata-1.000004.tar.gz
07 wget http://mirror.teklinks.com/CPAN/authors/id/D/DA/DAGOLDEN/ExtUtils-CBuilder-0.280202.tar.gz
08 wget http://mirror.teklinks.com/CPAN/authors/id/D/DA/DAGOLDEN/ExtUtils-ParseXS-2.2206.tar.gz
09 wget http://mirror.teklinks.com/CPAN/authors/id/D/DA/DAGOLDEN/Module-Build-0.3800.tar.gz
10 wget http://ftp.osuosl.org/pub/CPAN/authors/id/A/AN/ANDYA/Test-Harness-3.23.tar.gz
11 wget http://ftp.wayne.edu/cpan/authors/id/M/MS/MSCHWERN/Test-Harness-Straps-0.30.tar.gz
12 wget http://mirror.metrocast.net/cpan/authors/id/Y/YV/YVES/ExtUtils-Install-1.54.tar.gz
13  
14 ### Error: ##################################################
15 [root@hexuweb102 Module-Build-0.3800]$ perl Makefile.PL
16 #*** BOOTSTRAPPING Perl::OSType ***
17 #*** BOOTSTRAPPING version ***
18 #*** BOOTSTRAPPING Module::Metadata ***
19 # running Build.PL
20 #*** BOOTSTRAPPING Perl::OSType ***
21 #*** BOOTSTRAPPING version ***
22 #*** BOOTSTRAPPING Module::Metadata ***
23 #Checking prerequisites...
24 #  requires:
25 #    !  CPAN::Meta is not installed
26 #    !  ExtUtils::CBuilder is not installed
27 #    !  ExtUtils::ParseXS is not installed
28 #  build_requires:
29 #    !  Parse::CPAN::Meta is not installed
30 #    !  Test::Harness (2.56) is installed, but we need version >= 3.16
31 #  recommends:
32 #    *  ExtUtils::Manifest (1.46) is installed, but we prefer to have 1.54
33  
34 #Checking optional features...
35 #inc_bundling_support....disabled
36 #  requires:
37 #    ! ExtUtils::Install (1.33) is installed, but we need version >= 1.54
38 #    ! ExtUtils::Installed (0.08) is installed, but we need version >= 1.999
39  
40 #ERRORS/WARNINGS FOUND IN PREREQUISITES.  You may wish to install the versions
41 #of the modules indicated above before proceeding with this installation
42  
43 #Could not create MYMETA files
44 #Creating new 'Build' script for 'Module-Build' version '0.3800'
45 #Copied META.yml to MYMETA.yml for bootstrapping
46  
47 #These additional prerequisites must be installed:
48 #  requires:
49 #    ! Perl::OSType (we need version 1.00)
50 #    ! version (we need version 0.87)
51 #    ! Module::Metadata (we need version 1.000002)
52  
53 #These additional prerequisites must be installed:
54 #  requires:
55 #    ! Perl::OSType (we need version 1.00)
56 #    ! version (we need version 0.87)
57 #    ! Module::Metadata (we need version 1.000002)

安装 Module-Build 依赖库:

1 ### install: ...............................................
2 [root@hexuweb102 monitor]$ tar zxvf Perl-OSType-1.002.tar.gz
3 [root@hexuweb102 monitor]$ cd Perl-OSType-1.002
4 [root@hexuweb102 Perl-OSType-1.002]$ perl Makefile.PL
5  
6 ### Error: ##################################################
7 # ExtUtils::MakeMaker version 6.31 required--this is only version 6.30 at Makefile.PL line 7.
8 # BEGIN failed--compilation aborted at Makefile.PL line 7.

再次需要其它依赖库:

01 ### Dowlad Softs: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
02 ### Dowlad Softs: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
04 wget: http://ftp.wayne.edu/cpan/authors/id/M/MS/MSCHWERN/ExtUtils-MakeMaker-6.58.tar.gz
05  
06 ### install: ...............................................
07 [root@hexuweb102 monitor]$ tar zxvf ExtUtils-MakeMaker-6.58.tar.gz
08 [root@hexuweb102 monitor]$ cd ExtUtils-MakeMaker
09 [root@hexuweb102 ExtUtils-MakeMaker]$ perl Makefile.PL
10 [root@hexuweb102 ExtUtils-MakeMaker]$ make & make intall
11  
12 ### install: ...............................................
13 [root@hexuweb102 Perl-OSType-1.002]$ perl Makefile.PL
14 [root@hexuweb102 Perl-OSType-1.002]$ make & make intall

接着安装上面下载的所有库文件:

01 ### install: ...............................................
02 [root@hexuweb102 Module-Metadata-1.000004]$ per Makefile.PL
03 [root@hexuweb102 Module-Metadata-1.000004]$ make & make install
04  
05 ### install: ...............................................
06 [root@hexuweb102 ExtUtils-ParseXS-2.2206]$ per Makefile.PL
07 [root@hexuweb102 ExtUtils-ParseXS-2.2206]$ make & make install
08  
09 ### install: ...............................................
10 [root@hexuweb102 Test-Harness]$ per Makefile.PL
11 [root@hexuweb102 Test-Harness]$ make & make install
12  
13 ### install: ...............................................
14 [root@hexuweb102 ExtUtils-Install-1.54]$ per Makefile.PL
15 [root@hexuweb102 ExtUtils-Install-1.54]$ make & make install

上面所有库安装完成后,再试一下Make:

01 ################################################################
02 ### re-make munin: Fail
03 ################################################################
04 [root@hexuweb102 munin-1.4.6]$ make
05  
06 ### Error: ##################################################
07 #Checking prerequisites...
08 #  requires:
09 #    !  HTML::Template is not installed
10 #    !  Log::Log4perl is not installed
11 #........
12 #........
13 #........
14 #cd node && /usr/bin/perl Build.PL
15 #Checking prerequisites...
16 #  requires:
17 #    !  Net::Server is not installed
18 #  recommends:
19 #    *  Net::SNMP is not installed

还需要 Net::Server/Net::SNMP,下载安装:

01 ### Dowlad Softs: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
02 ### Dowlad Softs: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
03 wget http://mirror.metrocast.net/cpan/authors/id/S/SA/SAMTREGAR/HTML-Template-2.9.tar.gz
04 wget http://mirror.cc.columbia.edu/pub/software/cpan/authors/id/M/MS/MSCHILLI/Log-Log4perl-1.33.tar.gz
05 wget http://cpan.erlbaum.net/authors/id/R/RH/RHANDOM/Net-Server-0.99.tar.gz
06 wget http://cpan.mirrors.hoobly.com/authors/id/D/DT/DTOWN/Net-SNMP-v6.0.1.tar.gz
07  
08 ### Error: ##################################################
09 [root@hexuweb102 Net-SNMP-v6.0.1]$ perl Makefile.PL
10 #Checking if your kit is complete...
11 #Looks good
12 #Warning: prerequisite Crypt::DES 2.03 not found.
13 #Writing Makefile for Net::SNMP
14 #Writing MYMETA.yml and MYMETA.json
15  
16 ### Dowlad Softs: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
17 ### Dowlad Softs: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
18 wget http://cpan.llarian.net/authors/id/D/DP/DPARIS/Crypt-DES-2.05.tar.gz
19  
20 ### install: ...............................................
21 [root@hexuweb102 Net-SNMP-v6.0.1]$ perl Makefile.PL
22 [root@hexuweb102 Net-SNMP-v6.0.1]$ make & make install
23  
24 ################################################################
25 ### re-make munin: success
26 ################################################################
27 [root@hexuweb102 munin-1.4.6]$ make ## success
28  
29 ### Create munin user
30 [root@hexuweb102 munin-1.4.6]$ useradd munin
31  
32 ### install: ...............................................
33 [root@hexuweb102 munin-1.4.6]$ make install

这里要注意,以munin身份设置Crontab

1 ### setup crontab
2 [munin@hexuweb102 ~]$ su - munin
3 [munin@hexuweb102 ~]$ crontab -l
4 */5 * * * * /opt/munin/bin/munin-cron

设置前或后,可以测试是否真正成功了:

1 ################################################################
2 ### munin-cron: fail
3 ################################################################
4  
5 [munin@hexuweb102 munin]$ /opt/munin/bin/munin-cron
6 #Can't locate RRDs.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/Utils.pm line 22.

上面原因是没有安装 rrdtool,下载安装:

01 ### Dowlad Softs: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
02 ### Dowlad Softs: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
05  
06 ### install: ...............................................
07 ### rrdtool 依赖 tcl lib 所以要先安装 TCL
08 [root@hexuweb102 munin]$ unzip tcl8510-src.zip
09 [root@hexuweb102 munin]$ cd /tcl8.5.10/unix/
10 [root@hexuweb102 unix]$ ./configure --enable-shared
11 [root@hexuweb102 unix]$ make & make install
12  
13 ### install: 自动安装依赖,也可以下载tar.gz包手动安装............
14 yum install cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel
15  
16 ### install: ...............................................
17 [root@hexuweb102 munin]$ tar zxvf rrdtool-1.4.5.tar.gz
18 [root@hexuweb102 munin]$ cd rrdtool-1.4.5
19 ##--enable-perl-site-install# 防止munin-cront找不到安装成功的rrdtool
20 [root@hexuweb102 rrdtool-1.4.5]$ ./configure --enable-perl-site-install
21 [root@hexuweb102 rrdtool-1.4.5]$ make & make install

查看rrdtool是否安装成功,通过下面命令,如果有信息显示,表示安装成功。

1 [root@hexuweb102 munin]$ /opt/rrdtool-1.4.5/bin/rrdtool -v
2 #RRDtool 1.4.5  Copyright 1997-2010 by Tobias Oetiker < tobi@oetiker.ch >
3 #Compiled Jul 16 2011 21:40:34
4 #....
5 #....

安装成功,检查是否还有问题:

01 [munin@hexuweb102 munin]$ /opt/munin/bin/munin-cron
02 ################################################################
03 ### ./munin-cron: fail
04 ################################################################
05 #Can't locate RRDs.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/Utils.pm line 22.
06 #BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/Utils.pm line 22.
07 #Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/UpdateWorker.pm line 18.
08 #BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/UpdateWorker.pm line 18.
09 #Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/Update.pm line 17.
10 #BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/Update.pm line 17.
11 #Compilation failed in require at /opt/munin/lib/munin-update line 13.
12 #BEGIN failed--compilation aborted at /opt/munin/lib/munin-update line 13.
13 #########################################################################

是因为RRDs.pm模块没有安装成功.有一个解决办法,一个避免的办法:
1. 解决办法: 将RRDs.pm复制到perl目录内:

1 [root@hexuweb102 rrdtool-1.4.5]$ cp -rp /opt/rrdtool-1.4.5/lib/perl/5.8.8/x86_64-linux-thread-multi/* /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/

2. 避免办法:安装rrdtool时添加 “–enable-perl-site-install” 即可。
所以在安装时通过此方法解决, 没有错误信息了.

1 [root@hexuweb102 rrdtool-1.4.5]$ ./configure --enable-perl-site-install

接下来启动 munin-node, 注意要以Root身份启动:

1 [root@hexuweb102 munin]$ /opt/munin/sbin/munin-node

启动本机的客户端:munin-node,运行完munin-node 后,你用 netstat -nl 查看,会有 4949的端口开了

1 [root@hexuweb102 monitor]$ netstat -nl
2 Active Internet connections (only servers)
3 Proto Recv-Q Send-Q Local Address               Foreign Address             State
4 tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN
5 tcp        0      0 0.0.0.0:4949                0.0.0.0:*                   LISTEN
6 .......
7 .......

然后你在web浏览器里看看你做的效果

1 [munin@hexuweb102 munin]$ /opt/munin/bin/munin-cron

这时可能会出现下面提示:

1 2011/07/17 10:14:59 [FATAL] There is nothing to do here, since there are no nodes with any plugins.  Please refer to http://munin-monitoring.org/wiki/FAQ_no_graphs at /opt/munin/lib/munin-html line 38

原因是没有任何 Plugins,使用下面命令可以查看已经准备好的可以使用的,你只选择就可以了:

01 [root@hexuweb102 munin# /opt/munin/sbin/munin-node-configure --suggest --shell
02 /*
03 ln -s '/opt/munin/lib/plugins/cpu' '/etc/opt/munin/plugins/cpu'
04 ln -s '/opt/munin/lib/plugins/df' '/etc/opt/munin/plugins/df'
05 ln -s '/opt/munin/lib/plugins/iostat' '/etc/opt/munin/plugins/iostat'
06 ln -s '/opt/munin/lib/plugins/load' '/etc/opt/munin/plugins/load'
07 ln -s '/opt/munin/lib/plugins/memory' '/etc/opt/munin/plugins/memory'
08 ln -s '/opt/munin/lib/plugins/swap' '/etc/opt/munin/plugins/swap'
09 .....
10 .....
11 .....
12 */

上面选择完成后,使用下面步骤生效:
1. Stop munin-node

1 [root@hexuweb102 munin]$ ps aux | grep muin
2 [root@hexuweb102 munin]$ kill muninId

2. Start munin-node

1 [root@hexuweb102 munin]$ /opt/munin/sbin/munin-node

3. re-run munin-cron

1 [munin@hexuweb102 munin]$ /opt/munin/bin/munin-cron

注意:
1. 有些plugins 是需要手动添加配置信息才可以生效的,比如:mysql的账号信息等。
2. plugins的配置文件在安装完成后可能没有,手动建议就可以,格式:

1 [root@hexuweb102 monitor]# vi /etc/opt/munin/plugin-conf.d/plugin.conf

格式:

1 [{插件名字前缀}* 或 插件名]
2 env.{根据不同插件文档中的介绍进行填写}

比如:

01 [phpfpm*]
03 env.ports 80
04 env.phpbin /usr/local/php/sbin/php-fpm
05  
06 [multips_memory]
07 env.os linux
08 env.names nginx mysqld php-fpm
09  
10 [mysql*]
11 env.mysqlopts -u{username}-p{password}

插件列表:

01 [root@hexuweb102 monitor]# ll /etc/opt/munin/plugins/
02 cpu -> /opt/munin/lib/plugins/cpu
03 df -> /opt/munin/lib/plugins/df
04 if_eth0 -> /opt/munin/lib/plugins/if_
05 iostat -> /opt/munin/lib/plugins/iostat
06 load -> /opt/munin/lib/plugins/load
07 memory -> /opt/munin/lib/plugins/memory
08 multips_memory -> /opt/munin/lib/plugins/multips_memory
09 munin_stats -> /opt/munin/lib/plugins/munin_stats
10 mysql_queries -> /opt/munin/lib/plugins/mysql_queries
11 mysql_slowqueries -> /opt/munin/lib/plugins/mysql_slowqueries
12 netstat -> /opt/munin/lib/plugins/netstat
13 nginx_combined -> /opt/munin/lib/plugins/nginx_combined
14 nginx_request -> /opt/munin/lib/plugins/nginx_request
15 nginx_status -> /opt/munin/lib/plugins/nginx_status
16 phpfpm_status -> /opt/munin/lib/plugins/phpfpm_status
17 swap -> /opt/munin/lib/plugins/swap

文章参考:
重点中重点看 munin-1.4.6/INSTALL
1. all

http://www.fxzc.net/archives/yuanmabaoanzhuangpeizhimunin.html

2. munin.conf

http://www.qqread.com/network/server/d358155.html

3. install rrdtool

http://hi.baidu.com/rhca/blog/item/51c67bcfe0d5d333f9dc6178.html

4. install rrdtool

http://xok.la/2008/08/cant_locate_rrds_pm_in_inc_inc.html


阅读更多
个人分类: 服务监控
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭