且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ganglia 3.4安装配置简述

更新时间:2022-09-15 19:28:08

   首先强调一下,Ganglia采用组播模式(多播模式)进行数据请求。gmetad发送一个请求到一个组播地址(239.2.11.71),由于是组播地址,所以gmetad只需发送一次请求包即可完成对所有gmond的轮询。gmond收到请求后将采集到的数据返回给gmetad。
      而单播模式下,Ganglia需要向每台服务器均发送一次轮询请求,这样的话,集群数量多了,主服务器光发送就会占用不小的带宽。但是单播模式也有其好处,在服务器分组,或跨网段的情况下,必须用单播模式。我早期的一篇博文《Ganglia分组监控》提到过个事情。

SERVER端安装: 

apache:

  1. wget http://labs.mop.com/apache-mirror//apr/apr-1.4.6.tar.gz  
  2. wget http://labs.mop.com/apache-mirror//apr/apr-util-1.5.1.tar.gz  
  3. wget http://www.fayea.com/apache-mirror/httpd/httpd-2.2.23.tar.gz   
  4.  
  5. tar -xf apr-1.4.6.tar.gz && cd apr-1.4.6  
  6. ./configure --prefix=/usr/local/apr && make && make install  
  7.  
  8. tar -xf apr-util-1.5.1.tar.gz && cd apr-util-1.5.1  
  9. ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr  
  10. make && make install   
  11.  
  12. tar -xf httpd-2.2.23.tar.gz && cd httpd-2.2.23  
  13. ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=most --with-included-apr --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util 
  14. make && make install  
  15. echo '/usr/local/apache2/bin/apachectl start' >>/etc/rc.d/rc.local  
  16.  
  17. 启动  
  18. /usr/local/apache2/bin/apachectl start 

php:
ganglia-web需要PHP JSON模块,该模块包含在PHP 5.2及其以上版本。PHP 5.1需要自行安装JSON模块,非常的麻烦。

  1. wget http://www.php.net/get/php-5.3.18.tar.gz/from/cn2.php.net/mirror  
  2. tar -xf php-5.3.18.tar.gz && cd php-5.3.18  
  3. ./configure --prefix=/usr/local/php-5.3 --with-apxs2=/usr/local/apache2/bin/apxs  
  4. make && make install 
vim /usr/local/apache2/conf/httpd.conf,添加如下内容:

  1. <FilesMatch \.php$>  
  2.     SetHandler application/x-httpd-php  
  3. </FilesMatch> 
  4.  
  5. <FilesMatch "\.ph(p[2-6]?|tml)$">  
  6.     SetHandler application/x-httpd-php  
  7. </FilesMatch> 
  8.  
  9. <FilesMatch "\.phps$">  
  10.     SetHandler application/x-httpd-php-source  
  11. </FilesMatch> 

  1. 找到<IfModule dir_module>配置段,添加index.php 
重启apache,写一个index.php文件,进行测试访问:
http://SERVER/index.php

安装ganglia依赖:
libconfuse:
官方网站下载失败,下载了版本稍旧一点rpm包:ttp://pkgs.repoforge.org/libconfuse/

  1. wget http://pkgs.repoforge.org/libconfuse/libconfuse-2.6-2.el5.rf.x86_64.rpm  
  2. wget http://pkgs.repoforge.org/libconfuse/libconfuse-devel-2.6-2.el5.rf.x86_64.rpm  
  3. rpm -ivh libconfuse-* 
pcre:

  1. wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz  
  2. tar -xf pcre-8.31.tar.gz && cd pcre-8.31  
  3. ./configure && make && make install  

  4. echo '/usr/local/lib' >/etc/ld.so.conf.d/libpcre.conf  
  5. ldconfig -v 
其它依赖:

  1. yum -y install apr-devel apr-util check-devel cairo-devel pango-devel libxml2-devel rpmbuild glib2-devel dbus-devel freetype-devel fontconfig-devel gcc-c++ expat-devel python-devel libXrender-devel  
rrdtool:

  1. wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz  
  2. tar -xf rrdtool-1.4.7.tar.gz && cd rrdtool-1.4.7  
  3. ./configure --prefix=/usr/local   
  4. make && make install  
  5.  
  6. echo '/usr/local/lib' >/etc/ld.so.conf.d/librrd.conf  
  7. ldconfig -v 
ganglia:

  1. wget http://sourceforge.net/projects/ganglia/files/ganglia%20monitoring%20core/3.4.0/ganglia-3.4.0.tar.gz/download   
  2. tar -xf ganglia-3.4.0.tar.gz && cd ganglia-3.4.0   
  3. ./configure --prefix=/usr/local/ganglia --with-gmetad --with-librrd=/usr/local/lib --sysconfdir=/etc/ganglia    
  4. make && make install   
  5.   
  6. cp gmond/gmond.init /etc/rc.d/init.d/gmond   
  7. cp gmetad/gmetad.init /etc/rc.d/init.d/gmetad   
  8. chkconfig --add gmond && chkconfig gmond on   
  9. chkconfig --add gmetad && chkconfig gmetad on 
  10.  
  11. 修改/etc/rc.d/init.d/gmetad和/etc/rc.d/init.d/gmond,分别指定如下参数:  
  12. GMETAD=/usr/local/ganglia/sbin/gmetad  
  13. GMOND=/usr/local/ganglia/sbin/gmond  

  1. mkdir -p /var/lib/ganglia/rrds 
  2. chown nobody:nobody /var/lib/ganglia/rrds 
  3.  
  4. gmond -t |tee /etc/ganglia/gmond.conf  
  5. vim /etc/ganglia/gmetad.conf,修改内容: 
  6. data_source "Hadoop Cluster" $SERVER:8649  //把$SERVER替换成自己的被监控服务器IP
  7. gridname "Hadoop" 
  8.  
  9. vim /etc/ganglia/gmond.conf,修改cluster配置段内容: 
  10. name = "Hadoop Cluster"   
ganglia-web:
早期版本ganglia-web组件是集成在ganglia安装包里的,一个名为web的目录;新版本的ganglia把两者分开了。

  1. wget http://sourceforge.net/projects/ganglia/files/ganglia-web/3.5.4/ganglia-web-3.5.4.tar.gz/download 
  2. tar -xf ganglia-web-3.5.4.tar.gz  
  3. cp -r ganglia-web-3.5.4 /usr/local/apache2/htdocs/ganglia 

  4. cd /usr/local/apache2/htdocs/ganglia 
  5. vim Makefile,修改参数GDESTDIR和APACHE_USER,然后执行make install进行安装: 
  6. GDESTDIR=/usr/local/apache2/htdocs/ganglia 
  7. APACHE_USER=daemon
  8.  
  9. make install
  10. cp conf_default.php conf.php
vim conf.php,修改如下参数:

  1. $conf['gmetad_root'] = "/var/lib/ganglia"; 
  2. $conf['rrds'] = "${conf['gmetad_root']}/rrds";    
  3. $conf['rrdtool'] = "/usr/local/bin/rrdtool"; 
  4. $conf['external_location'] = "http://SERVER/ganglia";  //把SERVER替换成自己的g
  5. $conf['case_sensitive_hostnames'] = false; 
启动并访问:

  1. service gmetad start 
  2. service gmond start 
  3. http://SERVER/ganglia/  //把SERVER替换成自己的ganglia服务器IP

CLIENT端安装:
比较简单,只需要安装gmond及其依赖即可,其它apache、php、rrdtool等都不需要安装。

  1. tar -xf ganglia-3.4.0.tar.gz && cd ganglia-3.4.0 
  2. ./configure --prefix=/usr/local/ganglia --sysconfdir=/etc/ganglia  
  3. make && make install 
  4.  
  5. cp gmond/gmond.init /etc/rc.d/init.d/gmond  
  6. chkconfig --add gmond && chkconfig gmond on  
  7.  
  8. 修改/etc/rc.d/init.d/gmond,指定如下参数: 
  9. GMOND=/usr/local/ganglia/sbin/gmond   
  10.  
  11. 复制配置文件到客户端,然后启动客户端: 
  12. scp SERVER:/etc/ganglia/gmond.conf /etc/ganglia 
 
CLIENT端的简单配置:
      最主要是修改cluster配置段中的name属性,要和gmetad.conf中的datasource里的名称一致;如果是分组监控,还要修改udp_send_channel、udp_recv_channel和tcp_accept_channel三个部分里的port。我在以前的ganglia 3.1.7安装配置及分组监控中都有说明。
      但是这次3.4的安装遇到了一点问题。ganglia server只能抓取到配有外网网卡的节点的数据,抓取不到仅配置内网网卡的的数据。最后参考了:http://www.howtocn.org/ganglia_how_to, 把239.2.11.71绑定到内网网卡上才解决了问题。      

  1. gmond节点安装完成后,运行命令:ip route add 239.2.11.71 dev eth1 
 
遇到的错误:
重启apache时报错:httpd: Syntax error on line 140 of /usr/local/apache2/conf/httpd.conf: Cannot load modules/mod_dir.so into server: /usr/local/apache2/modules/mod_dir.so: undefined symbol: apr_array_clear
解决:apache编译时需要指定参数--with-included-apr

ganglia web页面显示错误:It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. 
解决:
vim /etc/php.ini,修改如下参数:
date.timezone = PRC
vim /usr/local/apache2/htdocs/ganglia/header.php,在第二行添加:
date_default_timezone_set("PRC"); 

本文转自 li_qinshan 51CTO博客,原文链接:http://blog.51cto.com/share/1054385