Flume配置文件总结

组件命名一:单个source和sink用这个


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

组件命名二:单个source,多个sink用这个,当然有副本和负载均衡等模式


 
 
  1. # Name the components on this agent
  2. a1.sources = r1
  3. a1.sinks = k1 k2
  4. a1.channels = c1 c2
  5. # 将数据流复制给多个channel 副本,还有负载均衡
  6. a1.sources.r1.selector.type = replicating

一、source配置

1、netcat的source:bind指定IP,port指定port


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

2、读文件exec:commd中写命令,如果用tail的话记得用大写的F


 
 
  1. # Describe/configure the source
  2. a1.sources.r1.type = exec
  3. a1.sources.r1.command = tail -F /opt/ module/hive/logs/hive.log
  4. a1.sources.r1.shell = /bin/bash -c

3、读取文件夹source:spooldir source ,tmp记得一定要忽略


 
 
  1. # Describe/configure the source
  2. a1.sources.r1.type = spooldir
  3. # 指定文件夹
  4. a1.sources.r1.spoolDir = /opt/module/flume/upload
  5. #指定文件上传后的后缀
  6. a1.sources.r1.fileSuffix = .COMPLETED
  7. a1.sources.r1.fileHeader = true
  8. #忽略所有以.tmp结尾的文件,不上传
  9. a1.sources.r1.ignorePattern = ([^ ]*\.tmp)

4、最常用的source: arvo模式,bind指的是接收的主机,port不是随意的,是看sink给的端口


 
 
  1. # Describe/configure the source
  2. a1.sources.r1.type = avro
  3. a1.sources.r1.bind = hadoop102
  4. a1.sources.r1.port = 4141

二、sink配置文件

sink的选择特别多,常用的是hdfs,kafka,hbase,logger,同时还可能是avro,arvo主要是给下一个flume接收

1、hdfs的sink:


 
 
  1. # Describe the sink
  2. a1.sinks.k1.type = hdfs
  3. a1.sinks.k1.hdfs.path = hdfs://hadoop102:9000/flume/%Y%m%d/%H
  4. #上传文件的前缀
  5. a1.sinks.k1.hdfs.filePrefix = logs-
  6. #是否按照时间滚动文件夹
  7. a1.sinks.k1.hdfs.round = true
  8. #多少时间单位创建一个新的文件夹
  9. a1.sinks.k1.hdfs.roundValue = 1
  10. #重新定义时间单位
  11. a1.sinks.k1.hdfs.roundUnit = hour
  12. #是否使用本地时间戳
  13. a1.sinks.k1.hdfs.useLocalTimeStamp = true
  14. #积攒多少个Event才flush到HDFS一次
  15. a1.sinks.k1.hdfs.batchSize = 1000
  16. #设置文件类型,可支持压缩
  17. a1.sinks.k1.hdfs.fileType = DataStream
  18. #多久生成一个新的文件 单位是秒
  19. a1.sinks.k1.hdfs.rollInterval = 600
  20. #设置每个文件的滚动大小 128M
  21. a1.sinks.k1.hdfs.rollSize = 134217700
  22. #文件的滚动与Event数量无关
  23. a1.sinks.k1.hdfs.rollCount = 0
  24. #最小冗余数
  25. a1.sinks.k1.hdfs.minBlockReplicas = 1

2、arvo sink:hostname是IP指的是发送给谁,port指的是监听端口可以任意写


 
 
  1. a1.sinks.k2.type = avro
  2. a1.sinks.k2.hostname = hadoop102
  3. a1.sinks.k2.port = 4142

3、logger sink:  如果是像在控制台看打印,要在命令加,-Dflume.root.logger=INFO,console


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

4、hbase待续

三、channel的配置

channel主要分为memory  channel和file channel,如果是要求速度和不追求数据的完整性用,memory channel, 一般也都用它

1、memory channel:1000指的是队列的容量,100指的是sink取数据的时候最大值


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

2、file channel:见文档

四、channel 和source,sink的绑定

1、单个source和单个sink


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

2、单个source和多个


 
 
  1. # Bind the source and sink to the channel
  2. a1.sources.r1.channels = c1 c2
  3. a1.sinks.k1.channel = c1
  4. a1.sinks.k2.channel = c2

启动命令是:  bin/flume-ng agent --conf conf/ --name a1 --conf-file job/flume-dir-hdfs.conf

或者是bin/flume-ng agent  -a a1 -c conf/ --conf  -f job/flume-dir-hdfs.conf   a1不是乱写的

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值