[BD] Flume

什么是Flume

  • 采集日志,存在HDFS上
  • 分布式、高可用、高可靠的海量日志采集、聚合和传输系统
  • 支持在日志系统中定制各类数据发送方,用于收集数据
  • 支持对数据进行简单处理,写到数据接收方

组件

  • source
  • channel
  • sink

实例

  • 配置文件
 1 #bin/flume-ng agent -n a4 -f myagent/a4.conf -c conf -Dflume.root.logger=INFO,console
 2 #定义agent名, source、channel、sink的名称
 3 a4.sources = r1
 4 a4.channels = c1
 5 a4.sinks = k1
 6 
 7 #具体定义source
 8 a4.sources.r1.type = spooldir
 9 a4.sources.r1.spoolDir = /root/training/logs
10 
11 #具体定义channel
12 a4.channels.c1.type = memory
13 a4.channels.c1.capacity = 10000
14 a4.channels.c1.transactionCapacity = 100
15 
16 #定义拦截器,为消息添加时间戳
17 a4.sources.r1.interceptors = i1
18 a4.sources.r1.interceptors.i1.type = org.apache.flume.interceptor.TimestampInterceptor$Builder
19 
20 
21 #具体定义sink
22 a4.sinks.k1.type = hdfs
23 a4.sinks.k1.hdfs.path = hdfs://192.168.56.111:9000/flume/%Y%m%d
24 a4.sinks.k1.hdfs.filePrefix = events-
25 a4.sinks.k1.hdfs.fileType = DataStream
26 
27 #不按照条数生成文件
28 a4.sinks.k1.hdfs.rollCount = 0
29 #HDFS上的文件达到128M时生成一个文件
30 a4.sinks.k1.hdfs.rollSize = 134217728
31 #HDFS上的文件达到60秒生成一个文件
32 a4.sinks.k1.hdfs.rollInterval = 60
33 
34 #组装source、channel、sink
35 a4.sources.r1.channels = c1
36 a4.sinks.k1.channel = c1
View Code

猜你喜欢

转载自www.cnblogs.com/cxc1357/p/12709784.html
BD