为了账号安全,请及时绑定邮箱和手机立即绑定

ganalia+php+nginx+rrd 监控hadoop

标签:
PHP

两天的时间整理搭建了hadoop+ganalia监控系统

虚拟机3台 centos 6.5

192.168.24.192   h1  namenode gmond

192.168.24.190   h2  datanode ganalia监控 ganalia-web gmetad gmond

192.168.24.189   h2  datanode gmond 


软件下载

confuse-2.7                 http://www.nongnu.org/confuse/

http://sourceforge.net/projects/ganglia/files/?source=navbar



gmond

yum install gcc apr apr-devel libconfuse libconfuse-devel expat-devel pcre pcre-devel -y

如果需安装gmetad

yum install rrdtool rrdtool-devel  -y

如果需安装gweb

yum install rsync  -y


由于libconfuse库不能用yum安装,

tar –xzvf  confuse-2.7.tar.gz

cd  ./confuse-2.7

./configure CFLAGS=-fPIC -disable-nls

make

make install


安装ganglia(全部节点都要安装)

 tar -xzvf  ganglia-3.7.2.tar.gz

 cd ganglia-3.7.2

./configure --prefix=/usr/local/ganglia --with-gmetad --enable-gexec --with-python=/usr/local --with-librrd=/usr/bin

  make

  make install



gmetad配置 (主节点配置)

进入ganglia安装文件

cd ganglia-3.6.0

cp ./gmetad/gmetad.init  /etc/init.d/gmetad

chkconfig --add gmetad

vim /etc/init.d/gmetad

 修改如下(find / =name 'gmetad'搜索之):

GMETAD=/usr/local/ganglia/sbin/gmetad

mkdir -p /etc/ganglia

ln -s /usr/local/ganglia/etc/gmetad.conf /etc/ganglia/gmetad.conf




修改gmetad.conf配置文件


{每个data_source由3个字段组成 "名称" 指定轮询间隔(秒) 主机列表 }

节点分组

vim  /usr/local/ganglia/etc/gmetad.conf

///////////////////////////////////////////////  #

data_source "hadoop_namenode_h1" 10 192.168.24.192:8649

data_source "hadoop_datanode" 10 192.168.24.190:8650 192.168.24.189:8650

gridname "MyGrid XF hadoop test"

xml_port  8651

interactive_port  8652

rrd_rootdir  "/var/lib/ganglia/rrds"

case_sensitive_hostnames  0

//////////////////////////////////////////////

service gmetad restart (重启gmetad)


被监控节点安装ganglia

yum安装gmond:yum -y install ganglia-gmond  

或以下编译方式(由于本人在centos6.5上编译安装ganglia-gmond后,出现无法启动客户端,提示未识别的标识符模块,未能解决,最后采用yum解决;centos6.6 6.7均可编译安装)

yum install gcc apr apr-devel libconfuse libconfuse-devel expat-devel pcre pcre-devel -y

libconfuse  无法yum,看上面

cd /data/tools/

tar -axvf  ganglia-3.7.2.tar.gz

cd ganglia-3.7.2

./configure --prefix=/usr/local/ganglia --with-gmetad --enable-gexec --with-python=/usr/local --with-librrd=/usr/bin

make && make install


ganglia配置 所有节点

mkdir -p /etc/ganglia

cp gmond/gmond.init /etc/init.d/gmond

chkconfig --add gmond

vim /etc/init.d/gmond

修改如下(find / =name 'gmond'搜索之):

GMOND=/usr/local/ganglia/sbin/gmond

节点使用 生成配置文件 

mkdir /usr/local/ganglia/etc/

./gmond/gmond -t | tee /usr/local/ganglia/etc/gmond.conf 

ln -s /usr/local/ganglia/etc/gmond.conf  /etc/ganglia/gmond.conf


修改gmond.conf  分组,默认多播模式

vim /etc/ganglia/gmond.conf

send_metadata_interval = 30

cluster {

  name =  #对应gmetad中的data_source

  

  ...}

host {

  location = "190-h2" #随意起个名字

}

udp_send_channel {

  #mcast_join = 239.2.11.71    #默认多播,我这里使用的单播

  port = 8650          #注意修改对应端口 gmetad配置文件的data_source

  host = 192.168.24.189    #单播  gmetad配置文件的data_source

  ttl = 1

}

udp_recv_channel {

  #mcast_join = 239.2.11.71

  port = 8650

  #bind = 192.168.24.189   #本机ip

  retry_bind = true

  # Size of the UDP buffer. If you are handling lots of metrics you really

  # should bump it up to e.g. 10MB or even higher.

  # buffer = 10485760

}

tcp_accept_channel {

  port = 8650     #注意修改对应端口 gmetad配置文件的data_source

  # If you want to gzip XML output

  gzip_output = no

}

service gmond restart

------------------------------------------------------------------------


------------------------------------------------------------------------


节点分组 单播配置,可跨网段(多播默认配置即可)

ganglia配置文件中需要对应gmetad配置文件的data_source命名

udp_send_channel { #这段的host指向data_source命名后的配置地址即可实现单播

 host = 192.168.24.189


------------------------------------------------------------------------


安装ganglia-web(仅主节点安装)

 tar -zxvf ganglia-web-3.5.12.tar.gz

    cd ganglia-web-3.5.12/

    vim Makefile

GDESTDIR = /var/www/ganglia

APACHE_USER = apache                    # 与 /etc/php-fpm.d/www.conf 中user保持一致

    make install

修改配置文件

mkdir -p /var/lib/ganglia/rrds

chown nobody:nobody /var/lib/ganglia/rrds


安装PHP

    PHP5.3   XF

    yum install php-fpm php-common php-devel php-mysqlnd php-mbstring php-mcrypt -y


    PHP5.5

    yum --enablerepo=remi,remi-php55 install php-fpm php-common php-devel php-mysqlnd php-mbstring php-mcrypt

service php-fpm start



装nginx-1.9.7

        location ~ \.php$ {

            root           /var/www;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            include        fastcgi_params;

        }


cat /var/www/t.php 

<?php

phpinfo();

?>


主配置文件 nginx.conf加入  include conf.d/*.conf;

vim /usr/local/nginx/conf/conf.d/ganglia.conf 

location /ganglia {

   root   /var/www;

   index  index.html index.htm index.php;



点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消