首先,需要安装ganglia的以来包:
sudo apt-get install rrdtool apache2 php5
然后就可以安装ganglia了:
sudo apt-get install ganglia* 或者 sudo apt-get install ganglia-monitor gmetad ganglia-webfrontend
安装好后就可以配置ganglia了:
1)编辑/etc/ganglia/gmond.conf,修改cluster name:
cluster {
name = "scape1989"
owner = "unspecified"
latlong = "unspecified"
url = "unspecified"
}
2)编辑/etc/ganglia/gmetad.conf ,添加数据源和网格名称:
data_source "scape1989" localhost
gridname "scape"
如果有多台主机则需要在数据源那行增加所有主机的ip
配置好ganglia后需要重启gmond和gmetad服务:
重启主节点的gmetad服务:
/etc/init.d/gmetad restart
重启所有节点的gmond服务
/etc/init.d/ganglia-monitor restart
此时,我们需要将ganglia-webfronted的web相关代码链接到apache可以访问的位置或者移动到apache可以访问的目录:
sudo ln -s /usr/share/ganglia-webfrontend/ /var/www/ganglia
或者
sudo mv /usr/share/ganglia-webfrontend/ /var/www/ganglia
然后在浏览器输入http://localhost/ganglia 即可访问
绑定hadoop集群
hadoop-1.0.3的配置文件为:hadoop-1.0.3/conf/hadoop-metrics2.properties
将需要监控的项目前面注释去掉,*.servers的配置为 239.2.11.71:8649,这个地址是Ganglia的广播地址,是固定的;和gmond.conf文件的IP和端口是对应的,一致就可以
# for Ganglia 3.1 support
*.sink.ganglia.class=org.apache.hadoop.metrics2.sink.ganglia.GangliaSink31
*.sink.ganglia.period=10
# default for supportsparse is false
*.sink.ganglia.supportsparse=true
*.sink.ganglia.slope=jvm.metrics.gcCount=zero,jvm.metrics.memHeapUsedM=both
*.sink.ganglia.dmax=jvm.metrics.threadsBlocked=70,jvm.metrics.memHeapUsedM=40
namenode.sink.ganglia.servers=239.2.11.71:8649
datanode.sink.ganglia.servers=239.2.11.71:8649
jobtracker.sink.ganglia.servers=239.2.11.71:8649
tasktracker.sink.ganglia.servers=239.2.11.71:8649
maptask.sink.ganglia.servers=239.2.11.71:8649
reducetask.sink.ganglia.servers=239.2.11.71:8649
修改完,重启Ganglia和hadoop集群