flume学习(二)---source

  本文根据flume官网提供的Flume 1.8.0 User Guide整理得出的,主要包括flume1.8.0支持的各种source(如下表)及其说明。

  码一个网址:http://blog.csdn.net/accountwcx/article/details/49121663

source类别 type 数据来源 可靠性 说明
Avro Source avro external Avro client streams    
Thrift Source thrift external Thrift client streams    
Exec Source exec Unix command

不可靠

该命令必须能够连续地在标准输出(控制台)产生数据,如cat、tail -f等。反例:date

注意:对于Exec Source或者其他异步source,当flume接收数据失败时无法告知写入方接收数据失败。

(举例:当Exec Source执行的命令是tail -f log.txt时,其中log.txt是某个应用的日志文件,该应用会持续不断地写入日志文件。假设flume agent中的channel已经被写满,此时再有数据产生,flume已经无法处理,但flume无法告知该应用数据接收失败。因此,这部分数据就无法通过flume管道继续向下传输,即产生了数据丢失。)

JMS Source  jms

JMS destination

such as a queue or topic 

 

 可以使用任何JMS提供方,但只能使用ActiveMQ测试

Spooling Directory Source spooldir 磁盘上的某一具体目录 

可靠

 监测该目录中的文件变化并读取变动内容。

亮点:Spooling Directory Source是可靠的,即使flume进程被重启或者停止也不会丢失数据。

为了保证Spooling Directory Source的可靠性,其监测的目录必须遵循以下两条原则:

1.将某个文件移动到该目录后,不能再被写入内容;

2.该目录下每个文件的名称必须是唯一的,包括已经被flume处理的文件。

当该目录下某个文件被写入内容或者发生文件名冲突时,flume会输出错误信息并停止flume进程。

 Talidir Source  TAILDIR  文件组合(多个文件)

可靠

工作方式:近实时地监测各个文件,当某个文件有新行写入时,待文件写入完成,flume会读取新写入的行。

Twitter 1% firehose Source(实验性)

 org.apache.flume.source.twitter.TwitterSource

   

Experimental source that connects via Streaming API to the 1% sample twitter firehose,continously downloads tweets, converts them to Avro format and sends Avro events to a downstream Flume sink.

注意:这个source是实验性提供,在flume的每个小版本中都可能变动,在应用时请留意版本并考察其稳定性。

 Kafka Source

 org.apache.flume.source.kafka.KafkaSource

 Kafka topics    
 NetCat TCP Source  netcat  某个TCP端口接收到的数据    工作方式:监听某个TCP端口,将每行数据都转换成一个event并进行传输。
NetCat UDP Source netcatudp 某个UDP端口接收到的数据   工作方式:监听某个UDP端口,将每行数据都转换成一个event并进行传输。
Sequence Generator Source seq 自己生成  

工作方式:一个简单的序列生成器(由0到totalEvents,步进值为1,默认的totalEvents是java Long型数据的最大值)。主要用于测试。

注意:当无法向channel发送event时,本source会重新尝试发送。

Syslog TCP Source syslogtcp 单个TCP端口产生的系统日志  

这三个source同属于Syslog Sources,工作方式都类似:

工作方式:Reads syslog data and generate Flume events.The UDP source treats an entire message as a single event. The TCP sources create a new event for each string of characters separated by a newline (‘n’).

Multiport Syslog TCP Source multiport_syslogtcp 多个TCP端口产生的系统日志  
Syslog UDP Source syslogudp 单个UDP端口产生的系统日志  
HTTP Source http

通过HTTP POST/GET

发送的event数据

 

注意:1.GET方式是实验性的

   2.HTTP requests are converted into flume events by a     pluggable “handler” which must implement the                      HTTPSourceHandler interface.

Stress Source

org.apache.flume.source.StressSource

自己生成  

内部负载生成source,主要用于压力测试,可以配置event的负载大小。

Avro Legacy Source

org.apache.flume.source.avroLegacy.AvroLegacySource

Flume 0.9.4 agents  

这两个source同属于一个大类:Legacy Sources,负责接收Flume 0.9.4 agents发送的events并转换成Flume 1.0 format,然后存储在指定的channel中。

Thirft Legacy Source

org.apache.flume.source.thriftLegacy.ThriftLegacySource

 
Custom Source 自定义的FQCN 自定义  

A custom source is your own implementation of the Source interface. A custom source’s class and its dependencies must be included in the agent’s classpath when starting the Flume agent.

The type of the custom source is its FQCN.

Scribe Source

org.apache.flume.source.scribe.ScribeSource

外部的scribe客户端  

Scribe is another type of ingest system. To adopt existing Scribe ingest system, Flume should use ScribeSource based on Thrift with compatible transfering protocol. For deployment of Scribe please follow the guide from Facebook.(scribe是Facebook公司开发的,所以需要结合Facebook提供的文档进行开发)

 

  

posted @ 2018-02-06 12:21  赵庆-BUPT  阅读(220)  评论(0编辑  收藏  举报