配置文件
a1.sources = r1
a1.channels = c1
a1.sinks = k1
a1.sources.r1.type=spooldir
a1.sources.r1.spoolDir=/root/data/hbreal
a1.sources.r1.fileHeader=true
#a1.sinks.k1.type=logger
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.kafka.topic = hbreal
a1.sinks.k1.brokerList = s2:9092
a1.sinks.k1.kafka.flumeBatchSize = 20
a1.sinks.k1.kafka.producer.acks = 1
a1.channels.c1.type=memory
a1.sources.r1.channels=c1
a1.sinks.k1.channel=c1
选择file作为channel
a1.channels.c1.type = file
a1.channels.c1.checkpointDir = /root/flumedata/checkpoint
a1.channels.c1.transactionCapacity = 1000000
a1.channels.c1.dataDirs = /root/flumedata/data
启动flume
flume-ng agent -f ./flumeconfig/flume_spooldir.conf -n a1 -Dflume.root.logger=INFO,console