Flume 监控之Ganglia

本文详细介绍Ganglia监控系统的安装部署过程,包括HTTPd、PHP及依赖软件包的安装,以及ganglia服务组件的配置与启动。同时,文章还介绍了如何在Flume中集成Ganglia监控,通过修改配置实现Flume运行状态的实时监控。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.Ganglia的安装与部署

(1) 安装httpd服务与php

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

(2) 安装其他依赖

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

    [luomk@hadoop102 flume]$ sudo yum -y install apr-devel

(3) 安装ganglia

    [luomk@hadoop102 flume]$ sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

    [luomk@hadoop102 flume]$ sudo yum -y install ganglia-gmetad

    [luomk@hadoop102 flume]$ sudo yum -y install ganglia-web

    [luomk@hadoop102 flume]$ sudo yum install -y ganglia-gmond    

(4) 修改配置文件ganglia.conf

    [luomk@hadoop102 flume]$ sudo vim /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) 修改配置文件gmetad.conf

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

    修改为:

data_source "hadoop102” 10.211.55.102

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

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

修改为:

cluster {

  name = "hadoop102"

  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 = 10.211.55.102

  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 = 10.211.55.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

}

(7) 修改配置文件config

    [luomk@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本次生效关闭必须重启,如果此时不想重启,可以临时生效之:[luomk@hadoop102 flume]$ sudo setenforce 0

(8) 启动ganglia

    [luomk@hadoop102 flume]$ sudo service httpd start

    [luomk@hadoop102 flume]$ sudo service gmetad start

    [luomk@hadoop102 flume]$ sudo service gmond start

(9) 打开网页浏览ganglia页面

    http://10.211.55.102/ganglia

尖叫提示:如果完成以上操作依然出现权限不足错误,请修改/var/lib/ganglia目录的权限:

    [luomk@hadoop102 flume]$ sudo chmod -R 777 /var/lib/ganglia

 

2.操作Flume测试监控

(1) 修改/opt/module/flume/conf目录下的flume-env.sh配置:

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

(2) 启动flume任务

[luomk@hadoop102 flume]$ bin/flume-ng agent \

--conf conf/ \

--name a1 \

--conf-file job/flume-telnet-logger.conf \

-Dflume.root.logger==INFO,console \

-Dflume.monitoring.type=ganglia \

-Dflume.monitoring.hosts=192.168.1.102:8649

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

    [luomk@hadoop102 flume]$ telnet localhost 44444

样式如图:

 

    图例说明:

字段(图表名称)

字段含义

EventPutAttemptCount

source尝试写入channel的事件总数量

EventPutSuccessCount

成功写入channel且提交的事件总数量

EventTakeAttemptCount

sink尝试从channel拉取事件的总数量。这不意味着每次事件都被返回,因为sink拉取的时候channel可能没有任何数据。

EventTakeSuccessCount

sink成功读取的事件的总数量

StartTime

channel启动的时间(毫秒)

StopTime

channel停止的时间(毫秒)

ChannelSize

目前channel中事件的总数量

ChannelFillPercentage

channel占用百分比

ChannelCapacity

channel的容量

 

### GangliaFlume的集成及其在监控系统中的应用 #### 集成背景 大规模分布式系统的监控对于确保服务稳定性和性能至关重要。Ganglia作为一种高效的集群监控工具,能够实时收集并展示节点状态数据[^2]。而Apache Flume则是一个高可靠、高性能的日志采集、聚合和传输系统,支持在日志系统中定制各类Source、Channel和Sink来实现复杂的数据流处理逻辑。 #### 数据流动机制 为了使这两个组件协同工作,在设计上可以考虑让Flume作为数据源(Source),负责捕获来自不同主机上的应用程序产生的各种事件或指标;接着通过配置合适的通道(Channel)将这些信息传递给目的地(Sink)[^3]。这里的目的地就是指运行着Ganglia gmond守护进程的服务端,它会接收到来自多个客户端发送过来的状态报告,并将其汇总到中央数据库里供后续分析使用。 #### 实现方案概述 具体来说,可以通过编写自定义插件的方式扩展Flume的功能,使其可以直接向Ganglia提交度量值。这通常涉及到开发一个新的sink类实例,该类实现了必要的接口以便于与其他模块交互。下面给出了一段简化版Python脚本用于说明如何创建这样一个简单的sink: ```python from flume import Source, Channel, Sink class GangliaSink(Sink): def __init__(self, collector_host='localhost', port=8649): super().__init__() self.collector_host = collector_host self.port = port def process(self, event): # 假设event包含了要上报给ganglia的信息 message = str(event) try: # 这里应该有实际连接gmond并将message发送出去的操作 pass except Exception as e: print(f"Failed to send data to ganglia: {e}") ``` 上述代码片段仅提供了一个框架性的指导思路,具体的实现细节还需要依据实际情况调整优化。此外,考虑到安全性和效率等因素的影响,在生产环境中部署前应当充分测试整个链路的有效性以及稳定性[^4]。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员学习圈

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值