最近接触了一下kafka, 想要从kafka每半小时获取数据用于更新学习, 找了相关的朋友推荐,是用flume来实现半小时日志回滚,具体代码如下
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = org.apache.flume.source.kafka.KafkaSource
a1.sources.r1.batchSize = 5000
a1.sources.r1.batchDurationMillis = 2000
a1.sources.r1.kafka.zookeeperConnect = host
a1.sources.r1.kafka.topics = topic
# Use a channel which buffers events in memory
a1.channels.c1.type = file
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
a1.sinks.k1.type = file_roll
a1.sinks.k1.sink.directory = /home/flume_log
a1.sinks.k1.sink.rollInterval=1800
a1.sinks.k1.channel = c1
日志是成功的每1800s生成了,但是不知道为什么有请求的情况下,日志仍旧是空的?是否在哪个地方有写得不对?
另外是否可以直接从kafka实现每半小时读取一次数据,或者半小时内的数据线写到缓存区, 半小时一到就写到文件里?