CDH的Flume配置Adding multiple flows in an agent

注意事项:

1)需求:

在CDH的Flume上面配置2个flows,2个flows的监控文件路径不一样,且将监控的文件发送到不同kafka中,最后删除读取完的文件

http://flume.apache.org/FlumeUserGuide.html#adding-multiple-flows-in-an-agent
http://flume.apache.org/FlumeUserGuide.html#adding-multiple-flows-in-an-agent

2)重点:在c2上面配置一个dataDirs ,如下:

a1.channels.c2.dataDirs = /home/flume/ssp/data

Property Name DefaultDescription
dataDirs~/.flume/file-channel/dataComma separated list of directories for storing log files. Using multiple directories on separate disks can improve file channel peformance

3)目录设定权限

chmod 777 /home/flume/ssp/checkpoint
chmod 777 /data/flumeSpool
chmod 777 /home/flume/ssp/checkpoint_ssp
chmod 777 /home/flume/ssp/data
chmod 777 /data/flumeSpool_ssp

4)配置如下:

a1.sources.src.interceptors.i2.type=org.apache.flume.sink.solr.morphline.UUIDInterceptor$Builder
这个配置的意思是:让kafka的key值随机,这样可以发送到不同Partition中去,解决Kafka数据倾向。

# Define a kafka channel 
a1.channels.c1.type = file
a1.channels.c1.checkpointDir = /home/flume/ssp/checkpoint
a1.channels.c1.capacity = 10000
a1.channels.c1.transactionCapacity = 1000
a1.channels.c1.kafka.consumer.timeout.ms=60000

# Define an spooldir source

a1.sources.src.type = spooldir
a1.sources.src.deletePolicy=immediate
a1.sources.src.spoolDir = /data/flumeSpool
a1.sources.src.interceptors = i2
a1.sources.src.interceptors.i2.type=org.apache.flume.sink.solr.morphline.UUIDInterceptor$Builder
a1.sources.src.interceptors.i2.headerName=key
a1.sources.src.interceptors.i2.preserveExisting=false

 
# Define a kafka sink
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.topic = nginx_log
a1.sinks.k1.brokerList =hadoop11:9092,hadoop12:9092,hadoop13:9092
a1.sinks.k1.requiredAcks = 1
a1.sinks.k1.batchSize = 20

# ssp data -- start --
a1.channels.c2.type = file
a1.channels.c2.checkpointDir = /home/flume/ssp/checkpoint_ssp
a1.channels.c2.dataDirs = /home/flume/ssp/data
a1.channels.c2.capacity = 10000
a1.channels.c2.transactionCapacity = 1000
a1.channels.c2.kafka.consumer.timeout.ms=60000

# Define an spooldir source

a1.sources.src2.type = spooldir
a1.sources.src2.deletePolicy=immediate
a1.sources.src2.spoolDir = /data/flumeSpool_ssp
a1.sources.src2.interceptors = i2
a1.sources.src2.interceptors.i2.type=org.apache.flume.sink.solr.morphline.UUIDInterceptor$Builder
a1.sources.src2.interceptors.i2.headerName=key
a1.sources.src2.interceptors.i2.preserveExisting=false

 
# Define a kafka sink
a1.sinks.k2.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k2.topic = ssp_nginx_log
a1.sinks.k2.brokerList =hadoop11:9092,hadoop12:9092,hadoop13:9092
a1.sinks.k2.requiredAcks = 1
a1.sinks.k2.batchSize = 20
# ssp data -- end --

# Finally, now that we've defined all of our components, tell
a1.channels = c1 c2
a1.sources = src src2
a1.sinks = k1 k2

# Bind the source and sink to the channel  
a1.sources.src.channels = c1 
a1.sinks.k1.channel = c1

a1.sources.src2.channels = c2 
a1.sinks.k2.channel = c2
北京小辉微信公众号

在这里插入图片描述

大数据资料分享请关注
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

北京小辉

你的鼓舞将是我最大的动力

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

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

打赏作者

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

抵扣说明:

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

余额充值