在运维hadoop的时候,经常会遇到一些性能问题。而性能问题,是无法简单通过web页面和log分析出来的。需要很多方面的指标。而Ganglia就是比较实用个监控工具之一。
部署Ganglia,百度一下,很多人已经分享很多。结合众人的经验。并加入自己安装过程中遇到的问题,整理出本文。
1. 准备了2台机器
1
2
3
4
|
Server 192.168.0.11(gmetad,web,gmond-master) Client 192.168.0.12(gmond) |
2. Server端需要安装的软件包
● epel包的安装:yum install -y epel-release(解决不能yum安装某些安装包的问题)
● gmetad的安装:yum install -y ganglia-gmetad ganglia-devel
● gmond的安装:yum install -y ganglia-gmond ganglia-gmond-python
● rrdtool的安装:yum install -y rrdtool rrdtool-devel
● httpd服务器的安装:yum install -y httpd
● ganglia-web及php安装:yum install -y ganglia-web php
● 其他依赖包的安装:yum install -y apr-devel zlib-devel libconfuse-devel expat-devel pcre-devel
3. 被监测节点需要安装的软件包
● epel包的安装:yum install -y epel-release(解决不能yum安装某些安装包的问题)
● gmond的安装:yum install -y ganglia-gmond ganglia-gmond-python
4. 安装目录说明
● ganglia配置文件目录:/etc/ganglia
● rrd数据库存放目录:/var/lib/ganglia/rrds
● httpd主站点目录:/var/www/html
● ganglia-web安装目录:/usr/share/ganglia
● ganglia-web配置目录:/etc/httpd/conf.d/ganglia.conf
5. 关闭SELINUX
1
2
3
|
vi /etc/selinux/config 把SELINUX=enforcing改成SELINUX=disable; 需要重启机器。 |
6. 关闭防火墙
1
2
3
|
# chkconfig iptables off # chkconfig iptables --list iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off |
7. 配置/etc/ganglia/gmetad.conf
修改data_source,改成:
1
|
data_source "testcluster” 192.168.0.11:8650 #gmetad采集数据的目标gmond地址和端口(tcp_accept_channel) |
8. 配置gmond
/etc/ganglia/gmond.conf,修改以下内容(这个gmond节点作为收集节点,这个节点可以是多个,最后需要在gmetad.conf上进行配置):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
cluster { name = "testcluster" #设置集群的名称
#owner = "unspecified" latlong = "unspecified"
url = "unspecified"
} #发送到目标gmond的地址和端口(单播) udp_send_channel { host=192.168.0.11 port = 8649 ttl = 1 } #接收udp的端口 udp_recv_channel { port = 8649 } #gmetad如果过来收集数据请求的端口 tcp_accept_channel { port = 8650 gzip_output = no } |
9. 配置web
软连接方式
1
|
>ln -s /usr/share/ganglia /var/www/ganglia |
也可以将/usr/share/ganglia的内容直接复制到/var/www/ganglia
10. 修改/etc/httpd/conf.d/ganglia.conf,改成:
1
2
3
4
5
|
Alias /ganglia /usr/share/ganglia <Location /ganglia> Order deny,allow Allow from all </Location> |
11. 启动服务
1
2
3
|
#service gmetad start #service gmond start #service httpd restart |
至此,Ganglia的server端已经部署完成。
配置客户端:
12. 客户端只要配置gmond即可(需要先安装yum -y install ganglia-gmond ganglia-gmond-python)
/etc/ganglia/gmond.conf,修改以下内容(这个gmond节点作为收集节点,这个节点可以是多个,最后需要在gmetad.conf上进行配置):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
cluster { name = "testcluster" #设置集群的名称
#owner = "unspecified" latlong = "unspecified"
url = "unspecified"
} #发送到目标gmond的地址和端口(单播) udp_send_channel { host=192.168.248.130 port = 8649 ttl = 1 } #接收udp的端口 udp_recv_channel { port = 8649 } #gmetad如果过来收集数据请求的端口 tcp_accept_channel { port = 8650 gzip_output = no } |
13. 配置HDFS、YARN集成Ganglia
修改hadoop-metrics2.properties
1
2
3
4
5
6
7
8
9
10
11
12
13
|
# 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=192.168.0.11:8649 # host请参考gmond.conf中的定义 datanode.sink.ganglia.servers=192.168.0.11:8649 resourcemanager.sink.ganglia.servers=192.168.0.11:8649 nodemanager.sink.ganglia.servers=192.168.0.11:8649 mrappmaster.sink.ganglia.servers=192.168.0.11:8649 jobhistoryserver.sink.ganglia.servers=192.168.0.11:8649 |
14. HBase集成Ganglia
修改hadoop-metrics2-hbase.properties
1
2
3
4
5
6
7
8
9
10
11
|
*.sink.file*. class =org.apache.hadoop.metrics2.sink.FileSink
# default sampling period *.period=10 *.source.filter. class =org.apache.hadoop.metrics2.filter.GlobFilter
*.record.filter. class =${*.source.filter. class }
*.metric.filter. class =${*.source.filter. class }
hbase.sink.ganglia.record.filter.exclude=*Regions* hbase.sink.ganglia. class =org.apache.hadoop.metrics2.sink.ganglia.GangliaSink31
hbase.sink.ganglia.tagsForPrefix.jvm=ProcessName *.sink.ganglia.period=20 hbase.sink.ganglia.servers=192.168.0.11:8649 # host请参考gmond.conf中的定义 |
15. 拷贝配置文件到每一个需要监控的机器上
将hadoop-metrics2.properties拷贝到$HADOOP_HOME/etc/hadoop/目录下
将hadoop-metrics2-hbase.properties拷贝到$HBASE_HOME/conf目录下
重新启动hadoop&hbase软件,令其生效。
16. 启动监控端的gmond
1
|
service gmond start |
问题汇总:
-
客户端已经有信息传递,能看到整体CPU load等信息
2. 但是各个节点的信息都是空的,显示“no matching metrics detected or rrds not readable”
3. 查看RRDs信息
# cd /var/lib/ganglia/rrds
# ll
drwxr-xr-x 5 ganglia ganglia 4096 Jan 17 08:50 azcluster
drwxr-xr-x 2 ganglia ganglia 36864 Jan 17 10:59 __SummaryInfo__
4. 文件夹名是小写的
# ll
drwxr-xr-x 2 ganglia ganglia 32768 Jan 17 10:58 azcbetadnl05.envazure.com
drwxr-xr-x 2 ganglia ganglia 4096 Jan 17 08:47 azcbetaldapl01.envazure.com
drwxr-xr-x 2 ganglia ganglia 36864 Jan 17 10:58 __SummaryInfo__
5. 数据都已经传递过来了
# ls azcbetadnl05.envazure.com/|more
boottime.rrd
bytes_in.rrd
bytes_out.rrd
cpu_aidle.rrd
disk_free_absolute_data1.rrd
disk_free_absolute_data2.rrd
disk_free_absolute_data3.rrd
disk_free_absolute_data4.rrd
disk_free_absolute_data5.rrd
disk_free_absolute_dev_shm.rrd
disk_free_absolute_mnt_resource.rrd
......
6. 原因:/var/lib/ganglia/rrds中对各个节点相应的文件夹是小写,如果节点的hostname中包含大写字母的话,这样就发现找不到数据了。
解决方法:修改gmetad.conf,将case_sensitive_hostnames的值设置为1
# ls /etc/ganglia/
drwxr-xr-x 2 root root 4096 Jan 17 08:36 conf.d
-rw-r--r-- 1 root root 171 Oct 12 2015 conf.php
-rw-r--r-- 1 root root 9834 Jan 17 08:44 gmetad.conf
-rw-r--r-- 1 root root 8756 Jan 17 08:45 gmond.conf
# vi gmetad.conf
# In earlier versions of gmetad, hostnames were handled in a case
# sensitive manner
# If your hostname directories have been renamed to lower case,
# set this option to 0 to disable backward compatibility.
# From version 3.2, backwards compatibility will be disabled by default.
# default: 1 (for gmetad < 3.2)
# default: 0 (for gmetad >= 3.2)
case_sensitive_hostnames 1 #设置为1,则不会将大写变成小写
7. 修改完之后,到RRDs目录下查看结果。
# cd /var/lib/ganglia/rrds/azcluster
没有什么变化
# ls -al
drwxr-xr-x 2 ganglia ganglia 32768 Jan 17 10:58 azcbetadnl05.envazure.com
drwxr-xr-x 2 ganglia ganglia 4096 Jan 17 08:47 azcbetaldapl01.envazure.com
drwxr-xr-x 2 ganglia ganglia 36864 Jan 17 10:58 __SummaryInfo__
8. 重启gmetad,让配置生效
1
2
3
|
# service gmetad restart Shutting down GANGLIA gmetad: [ OK ] Starting GANGLIA gmetad: [ OK ] |
9. 可以看到大写主机名的文件夹已经被创建
1
2
3
4
5
6
|
# ls -al drwxr-xr-x 2 ganglia ganglia 32768 Jan 18 02:09 azcbetadnl05.envazure.com drwxr-xr-x 2 ganglia ganglia 4096 Jan 18 02:10 AZcbetadnL05.envazure.com <<<<<< drwxr-xr-x 2 ganglia ganglia 4096 Jan 17 08:47 azcbetaldapl01.envazure.com drwxr-xr-x 2 ganglia ganglia 4096 Jan 18 02:10 AZcbetaLDAPL01.envazure.com <<<<<< drwxr-xr-x 2 ganglia ganglia 36864 Jan 18 02:09 __SummaryInfo__ |
10. 可以看到信息已经过来了
1
2
3
4
5
|
# ls -l AZcbetaLDAPL01.envazure.com -rw-rw-rw- 1 ganglia ganglia 630760 Jan 18 02:13 boottime.rrd -rw-rw-rw- 1 ganglia ganglia 630760 Jan 18 02:13 bytes_in.rrd -rw-rw-rw- 1 ganglia ganglia 630760 Jan 18 02:13 bytes_out.rrd -rw-rw-rw- 1 ganglia ganglia 630760 Jan 18 02:13 cpu_aidle.rrd |
11. 再看看网页显示,已经正常了。