首先强调一下,Ganglia采用组播模式(多播模式)进行数据请求。gmetad发送一个请求到一个组播地址(239.2.11.71),由于是组播地址,所以gmetad只需发送一次请求包即可完成对所有gmond的轮询。gmond收到请求后将采集到的数据返回给gmetad。
而单播模式下,Ganglia需要向每台服务器均发送一次轮询请求,这样的话,集群数量多了,主服务器光发送就会占用不小的带宽。但是单播模式也有其好处,在服务器分组,或跨网段的情况下,必须用单播模式。我早期的一篇博文《Ganglia分组监控》提到过个事情。
SERVER端安装:
wget http://labs.mop.com/apache-mirror//apr/apr-1.4.6.tar.gz wget http://labs.mop.com/apache-mirror//apr/apr-util-1.5.1.tar.gz wget http://www.fayea.com/apache-mirror/httpd/httpd-2.2.23.tar.gz tar -xf apr-1.4.6.tar.gz && cd apr-1.4.6 ./configure --prefix=/usr/local/apr && make && make install tar -xf apr-util-1.5.1.tar.gz && cd apr-util-1.5.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make && make install tar -xf httpd-2.2.23.tar.gz && cd httpd-2.2.23 ./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 make && make install echo '/usr/local/apache2/bin/apachectl start' >>/etc/rc.d/rc.local 启动 /usr/local/apache2/bin/apachectl start
wget http://www.php.net/get/php-5.3.18.tar.gz/from/cn2.php.net/mirror tar -xf php-5.3.18.tar.gz && cd php-5.3.18 ./configure --prefix=/usr/local/php-5.3 --with-apxs2=/usr/local/apache2/bin/apxs make && make install
<FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch "\.ph(p[2-6]?|tml)$"> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch "\.phps$"> SetHandler application/x-httpd-php-source </FilesMatch>
找到<IfModule dir_module>配置段,添加index.php
wget http://pkgs.repoforge.org/libconfuse/libconfuse-2.6-2.el5.rf.x86_64.rpm wget http://pkgs.repoforge.org/libconfuse/libconfuse-devel-2.6-2.el5.rf.x86_64.rpm rpm -ivh libconfuse-*
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz tar -xf pcre-8.31.tar.gz && cd pcre-8.31 ./configure && make && make install
echo '/usr/local/lib' >/etc/ld.so.conf.d/libpcre.conf ldconfig -v
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
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz tar -xf rrdtool-1.4.7.tar.gz && cd rrdtool-1.4.7 ./configure --prefix=/usr/local make && make install echo '/usr/local/lib' >/etc/ld.so.conf.d/librrd.conf ldconfig -v
wget http://sourceforge.net/projects/ganglia/files/ganglia%20monitoring%20core/3.4.0/ganglia-3.4.0.tar.gz/download tar -xf ganglia-3.4.0.tar.gz && cd ganglia-3.4.0 ./configure --prefix=/usr/local/ganglia --with-gmetad --with-librrd=/usr/local/lib --sysconfdir=/etc/ganglia make && make install cp gmond/gmond.init /etc/rc.d/init.d/gmond cp gmetad/gmetad.init /etc/rc.d/init.d/gmetad chkconfig --add gmond && chkconfig gmond on chkconfig --add gmetad && chkconfig gmetad on 修改/etc/rc.d/init.d/gmetad和/etc/rc.d/init.d/gmond,分别指定如下参数: GMETAD=/usr/local/ganglia/sbin/gmetad GMOND=/usr/local/ganglia/sbin/gmond
mkdir -p /var/lib/ganglia/rrds chown nobody:nobody /var/lib/ganglia/rrds gmond -t |tee /etc/ganglia/gmond.conf vim /etc/ganglia/gmetad.conf,修改内容: data_source "Hadoop Cluster" $SERVER:8649 //把$SERVER替换成自己的被监控服务器IP gridname "Hadoop" vim /etc/ganglia/gmond.conf,修改cluster配置段内容: name = "Hadoop Cluster"
wget http://sourceforge.net/projects/ganglia/files/ganglia-web/3.5.4/ganglia-web-3.5.4.tar.gz/download tar -xf ganglia-web-3.5.4.tar.gz cp -r ganglia-web-3.5.4 /usr/local/apache2/htdocs/ganglia
cd /usr/local/apache2/htdocs/ganglia
vim Makefile,修改参数GDESTDIR和APACHE_USER,然后执行make install进行安装: GDESTDIR=/usr/local/apache2/htdocs/ganglia APACHE_USER=daemon make install
cp conf_default.php conf.php
$conf['gmetad_root'] = "/var/lib/ganglia"; $conf['rrds'] = "${conf['gmetad_root']}/rrds"; $conf['rrdtool'] = "/usr/local/bin/rrdtool"; $conf['external_location'] = "http://SERVER/ganglia"; //把SERVER替换成自己的g $conf['case_sensitive_hostnames'] = false;
service gmetad start service gmond start http://SERVER/ganglia/ //把SERVER替换成自己的ganglia服务器IP
tar -xf ganglia-3.4.0.tar.gz && cd ganglia-3.4.0 ./configure --prefix=/usr/local/ganglia --sysconfdir=/etc/ganglia make && make install cp gmond/gmond.init /etc/rc.d/init.d/gmond chkconfig --add gmond && chkconfig gmond on 修改/etc/rc.d/init.d/gmond,指定如下参数: GMOND=/usr/local/ganglia/sbin/gmond 复制配置文件到客户端,然后启动客户端: scp SERVER:/etc/ganglia/gmond.conf /etc/ganglia
gmond节点安装完成后,运行命令:ip route add 239.2.11.71 dev eth1