环境:
centos6.10
hadoop-3.1.3
hbase-2.1.10
ganglia-6.8
节点:
主机名:IP地址 | 进程 |
---|---|
myhbase:192.168.130.28(从) | secondrynamenode datanode hregionserver |
xmhl :192.168.130.29(主) | namenode datanode hmaster |
xmhl30:192.168.130.30 (从) | datanode hregionserver |
Ganglia组成:
Ganglia 由 gmond、gmetad 和 gweb 三部分组成。
gmond(Ganglia Monitoring Daemon)是一种轻量级服务,安装在每台需要收集指标
数据的节点主机上。使用 gmond,你可以很容易收集很多系统指标数据,如 CPU、内存、磁盘、网络和活跃进程的数据等。
gmetad(Ganglia Meta Daemon)整合所有信息,并将其以 RRD 格式存储至磁盘的服务。
gweb(Ganglia Web)Ganglia 可视化工具,gweb 是一种利用浏览器显示 gmetad 所存储数据的 PHP 前端。在 Web 界面中以图表方式展现集群的运行状态下收集的多种不同指标数据。
这里我们在主节点上安装gmond、gmetad 和 gweb,在其他从节点上只需要安装gmond。
Ganglia安装部署:
1、每个节点都需要执行:
1、安装 httpd 服务与 php
yum -y install httpd php
2、安装其他依赖
sudo yum -y install rrdtool perl-rrdtool rrdtool-devel
sudo yum -y install apr-devel
3、安装 ganglia sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
2、主节点执行:
sudo yum -y install ganglia-gmetad
sudo yum -y install ganglia-web
sudo yum -y install ganglia-gmond
3、从节点执行:
sudo yum -y install ganglia-gmond
4、主节点修改配置文件/etc/httpd/conf.d/ganglia.conf
vi /etc/httpd/conf.d/ganglia.conf
#
# Ganglia monitoring system php web frontend
#
Alias /ganglia /usr/share/ganglia
<Location /ganglia>
Order deny,allow
#Deny from all
Allow from all
#Allow from 127.0.0.1
#Allow from ::1
# Allow from .example.com
</Location>
5、主节点修改配置文件/etc/ganglia/gmetad.conf
vi /etc/ganglia/gmetad.conf
找到这一行并修改为如下:
data_source "hadoop" 192.168.130.29:8649 192.168.130.28:8649 192.168.130.30:8649
(“hadoop”是集群名字随便取一个,地址为三台服务器的地址,端口号为默认8649)
6、每个节点都需要修改配置文件/etc/ganglia/gmond.conf
vi /etc/ganglia/gmond.conf
需要修改的位置如下:
cluster {
name = "hadoop" #与上一步中的名字保持一致
owner = "unspecified"
latlong = "unspecified"
url = "unspecified"
}
/* The host section describes attributes of the host, like the location */
host {
location = "unspecified"
}
/* Feel free to specify as many udp_send_channels as you like. Gmond
used to only support having a single channel */
udp_send_channel {
#bind_hostname = yes # Highly recommended, soon to be default.
# This option tells gmond to use a source address
# that resolves to the machine's hostname. Without
# this, the metrics may appear to come from any
# interface and the DNS names associated with
# those IPs will be used to create the RRDs.
#mcast_join = 239.2.11.71 #这一行需要注释掉
host = 192.168.130.29 #加上自己的主节点地址
port = 8649
ttl = 1
}
/* You can specify as many udp_recv_channels as you like as well. */
udp_recv_channel {
#mcast_join = 239.2.11.71 #这一行需要注释掉
port = 8649
#bind = 239.2.11.71 #这一行需要注释掉
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
}
至此Ganglia就已经部署完成了,我们先不启动,实现Hadoop和hbase可以被监控以后再启动。
实现Ganglia监控Hadoop和hbase
1、修改Hadoop配置文件hadoop-metrics2.properties,每个节点都需要修改
vi /usr/local/hadoop-3.1.3/etc/hadoop/hadoop-metrics2.properties
添加如下配置:
(注意:修改之前把此文件中的所有内容都注释掉,中间有几行没有被注释,需要仔细看)
*.sink.ganglia.class=org.apache.hadoop.metrics2.sink.ganglia.GangliaSink31
*.sink.ganglia.period=10
*.sink.ganglia.slope=jvm.metrics.gcCount=zero,jvm.metrics.memHeapUsedM=both
*.sink.ganglia.dmax=jvm.metrics.threadsBlocked=70,jvm.metrics.memHeapUsedM=40
#namenode地址
namenode.sink.ganglia.servers=192.168.130.29:8649
#resourcemanager地址
resourcemanager.sink.ganglia.servers=192.168.130.29:8649
#datanode节点地址,中间用逗号隔开
datanode.sink.ganglia.servers=192.168.130.28:8649,192.168.130.29:8649,192.168.130.30:8649
nodemanager.sink.ganglia.servers=192.168.130.28:8649,192.168.130.29:8649,192.168.130.30:8649
2、修改hbase配置文件hadoop-metrics2-hbase.properties,每个节点都需要修改
vi /usr/local/hbase-2.1.10/conf/hadoop-metrics2-hbase.properties
添加如下配置:
(注意:修改之前把此文件中的所有内容都注释掉,中间有几行没有被注释,需要仔细看)
*.sink.ganglia.class=org.apache.hadoop.metrics2.sink.ganglia.GangliaSink31
*.sink.ganglia.period=10
hbase.sink.ganglia.period=10
#hbase主节点地址
hbase.sink.ganglia.servers=192.168.130.29:8649
3、启动ganglia
主节点:
service httpd start
service gmetad start
service gmond start
从节点:
service gmond start
ganglia的可视化页面:http://192.168.130.29/ganglia
在这里可以看到刚才的集群,我的集群名称是Hadoop
这里可以看到三个节点的主机名