Flume 数据流监控——Ganglia的安装与部署

1、Ganglia的安装

(1) 安装 dhttpd 服务与 php

[yasin@hadoop102 flume]$ sudo yum -y install httpd php

(2)安装其他依赖

[atguigu@hadoop102 flume]$ sudo yum -y install rrdtool perl-rrdtool
rrdtool-devel
[atguigu@hadoop102 flume]$ sudo yum -y install apr-devel

(3)安装 ganglia

[yasin@hadoop102  flume]$ sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-13.noarch.rpm
[yasin@hadoop102 flume]$ sudo yum -y install ganglia-gmetad
[yasin@hadoop102 flume]$ sudo yum -y install ganglia-web
[yasin@hadoop102 flume]$ sudo yum -y install ganglia-gmond

Ganglia 由 gmond、gmetad 和 gweb 三部分组成。
gmond(Ganglia Monitoring Daemon)是一种轻量级服务,安装在每台需要收集指标数据的节点主机上。使用 gmond,你可以很容易收集很多系统指标数据,如 CPU、内存、磁盘、网络和活跃进程的数据等。

gmetad(Ganglia Meta Daemon)整合所有信息,并将其以 RRD 格式存储至磁盘的服务。

gweb(Ganglia Web)Ganglia 可视化工具,gweb 是一种利用浏览器显示 gmetad 所存储数据的 PHP 前端。在 Web 界面中以图表方式展现集群的运行状态下收集的多种不同指标数据。

(4)修改配置文件 /etc/httpd/conf.d/ganglia.conf

[yasin@hadoop102 flume]$ sudo vim /etc/httpd/conf.d/ganglia.conf

注释掉Deny from all,增加Allow from all:

# 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

[yasin@hadoop102 flume]$ sudo vim /etc/ganglia/gmetad.conf

修改内容(其中hadoop102为自己的hadoop名,192.168.10.102为对应ip):

data_source "hadoop102" 192.168.10.102

(6)修改配置文件 /etc/ganglia/gmond.conf

[yasin@hadoop102 flume]$ sudo vim /etc/ganglia/gmond.conf

修改cluster中name为hadoop102;udp_send_channel中的host为192.168.10.102;dp_recv_channel中bind为:192.168.10.102:

cluster {
	name = "hadoop102"
	owner = "unspecified"
	latlong = "unspecified"
	url = "unspecified"
}
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.10.102
	port = 8649
	ttl = 1
}
udp_recv_channel {
	# mcast_join = 239.2.11.71
	port = 8649
	bind = 192.168.10.102
	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
}

修改配置文件 /etc/selinux/config

[yasin@hadoop102 flume]$ sudo vim /etc/selinux/config

修改为:

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

提示:selinux 本次生效关闭必须重启,如果此时不想重启,可以临时生效之:

[yasin@hadoop102 flume]$ sudo setenforce 0

2、Ganglia服务启动

(1)启动 ganglia

[atguigu@hadoop102 flume]$ sudo service httpd start
[atguigu@hadoop102 flume]$ sudo service gmetad start
[atguigu@hadoop102 flume]$ sudo service gmond start

(2)打开网页浏览 ganglia 页面:http://192.168.10.102/ganglia

提示:如果完成以上操作依然出现权限不足错误,请修改/var/lib/ganglia 目录的权限:
[atguigu@hadoop102 flume]$ sudo chmod -R 777 /var/lib/ganglia
如果修改权限后仍然提示权限不足参考:ganglia访问时出现"You don’t have permission to access /ganglia/ on this server"

3、测试监控

(1)修改f /opt/module/flume/conf 目录下的 flume-env.sh (从系统模板更名得来)配置,增加:

JAVA_OPTS="-Dflume.monitoring.type=ganglia -Dflume.monitoring.hosts=192.168.10.102:8649 -Xms100m -Xmx200m"

(2) 启动 Flume 任务

[yasin@hadoop102 flume]$ bin/flume-ng agent -c conf/ -f job/netcat-flume-logger.conf -n a1\
-Dflume.root.logger==INFO,console\
-Dflume.monitoring.type=ganglia\
-Dflume.monitoring.hosts=192.168.10.102:8649

其中job(flume下新建的目录)中netcat-flume-logger.conf配置为:

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444

# Describe the sink
a1.sinks.k1.type = logger

# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

(3)发送数据观察 aganglia 监测图

[yasin@hadoop102 flume]$ nc localhost 44444

字段含义说明:

Flume 数据流监控——Ganglia的安装与部署_第1张图片

你可能感兴趣的:(Flmue,flume,udp)