ganglia 3.4安裝配置簡述

      首先強調一下,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"); 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章