文章目录
  1. 1. flume介绍
  2. 2. flume基本组件架构
  3. 3. 可靠性
  4. 4. 事务
  5. 5. 可恢复性
  6. 6. flume支持级联模式
  7. 7. 多路技术
  8. 8. 分发数据流(Fan out flow)
  9. 9. 多种source
  10. 10. 多种sink
  11. 11. 多种channel
  12. 12. flume拦截器(flume interceptors)
  13. 13. flume轮询配置
  14. 14. 设计拓扑结构的一些考虑点
  15. 15. 一家之言

flume介绍

flume最新release版本是1.6.0
官方介绍:
Flume is a distributed, reliable, and available service for efficiently collecting, aggregating, and moving large amounts of log data. It has a simple and flexible architecture based on streaming data flows. It is robust and fault tolerant with tunable reliability mechanisms and many failover and recovery mechanisms. It uses a simple extensible data model that allows for online analytic application.

flume基本组件架构

Flume-basic

  • flume agent: 由若干source,channel,sink组成,其中source接收来自外源(external source)发送来的数据,然后将数据写入一个或多个channel,channel被动的存储接收的数据直到数据被sink消费。一个agent内的source和sink是借助于channle异步运行的(The source and sink within the given agent run asynchronously with the events staged in the channel.)
  • Event: event在flume里被定义为一个数据流的基本单位,event里包含可设置各种属性的header。
  • Client SDK: 提供了rpc client接口,比较特殊的包括Failover client(一组agents组成一个faileover group),以及LoadBalancing RPC client(一组agents组成load-balancing group,负载均衡策略可以是随机,R-R,或者自己定义)

可靠性

  • 数据(events)只有在被下一个agent中的channel存储或者发生到终端(terminal repository)后才会被从channel中删除。
    (The Sink removes an Event from the Channel only after the Event is stored into the Channel of the next agent or stored in the terminal repository. This is how the single-hop message delivery semantics in Flume provide end-to-end reliability of the flow.)
  • flume利用channel提供的事务性来保证数据分发的可靠性,这样可以确保数据流中端到端的数据可靠性。
    (The Sources and Sinks encapsulate the storage/retrieval of the Events in a Transaction provided by the Channel. )

事务

flume-transaction
如上图所示。

可恢复性

  • 数据被暂存在channel中,channel负责故障恢复。
  • channle支持持久化(本地文件)和非持久化(内存)两种模式。

flume支持级联模式

只需要配置上对应agent的source和sink即可。
flume-more-hop

多路技术

flume支持多路分发,支持一个源发布到多个端
flume-multiplexing
注意,一个source实例可以配置多个channel,但是一个sink只能配置指定到一个channel

分发数据流(Fan out flow)

  • 前面说道,flume支持从一个source到多个channel的多路分发技术,具体实现有两种方法,一个是复制(replicating),一个是多路技术(multiplexing)。
  • replicating模式中,数据会被发送到配置指定的所有channels。
  • multiplexing模式中,数据可能只会被发送到符合规则的channels中,可能是一个,多个或所有的。
  • 两种模式可以通过指定selector.type来选择,默认为replicating。
    如果指定的是multiplexing模式,则需要进一步指定规则,主要是通过header内容判断,然后分发到不同channel。
    如:
    1
    2
    3
    4
    5
    6
    agent_foo.sources.avro-AppSrv-source1.selector.type = multiplexing
    agent_foo.sources.avro-AppSrv-source1.selector.header = State
    agent_foo.sources.avro-AppSrv-source1.selector.mapping.CA = mem-channel-1
    agent_foo.sources.avro-AppSrv-source1.selector.mapping.AZ = file-channel-2
    agent_foo.sources.avro-AppSrv-source1.selector.mapping.NY = mem-channel-1 file-channel-2
    agent_foo.sources.avro-AppSrv-source1.selector.default = mem-channel-1

则selector会检查header中的state值,CA会发送到mem-channel-1,以此类推。

多种source

flume支持多种source,如Avro source, thrift source,exec source(命令行,如tail -f filelog),kafka source等等。
每个source实例都会有自己的生命周期,包括start(),stop(),process().

多种sink

flume支持多种sink,如hdfs sink,hive sink,logger sink, avro sink,thrift sink等等。
每个sink实例都会有自己的生命周期,包括start(),stop(),process().

多种channel

flume支持多种channel,如memory channel,file channel,kafka channel

flume拦截器(flume interceptors)

fulme具有修改或者丢弃接收到的数据(events)的能力。即对接收到的数据按照一定的配置规则处理。可以是增加字段,修改替换,过滤等。

flume轮询配置

flume agent会不断检查看配置文件是否修改更新,如果更新则会重新加载。

设计拓扑结构的一些考虑点

  1. flume适合将文本log数据写到HDFS。但可传输的数据可以多种多样,对flume来讲,会把接收的数据都看作是二进制数据。此外,你的拓扑结构可以修改,但不适合经常性的修改,但不适合每天都要修改(because reconfiguration takes some thought and overhead.)。
  2. 数据流的可靠性。channel类型选择,持久化还是内存型的,以及当channel满时情况,因为有可能造成数据丢失。以及是否使用冗余拓扑。(Whether you use redundant topologies.)
  3. 拓扑结构设计。如果源比较多的话是否使用聚合功能。
  4. 估算数据量,吞吐能力。

一家之言

优点:

  • 系统架构设计的非常清晰,组件之间耦合度非常低,可以根据需求自由组合;
  • 同时提供了多种source和sink,扩展性很强。

不足:

  • 配置不够灵活,尤其是需要动态更新一条数据流时;
  • 虽然提供了channel的事务,但是整个系统的异常处理能力还是比较弱的,不适合对数据质量要求较高的场景;
  • 用户接入的代价也比较高,以及运维是个挑战。
文章目录
  1. 1. flume介绍
  2. 2. flume基本组件架构
  3. 3. 可靠性
  4. 4. 事务
  5. 5. 可恢复性
  6. 6. flume支持级联模式
  7. 7. 多路技术
  8. 8. 分发数据流(Fan out flow)
  9. 9. 多种source
  10. 10. 多种sink
  11. 11. 多种channel
  12. 12. flume拦截器(flume interceptors)
  13. 13. flume轮询配置
  14. 14. 设计拓扑结构的一些考虑点
  15. 15. 一家之言