配置文件

    1. a1.sources = r1
    2. a1.channels = c1
    3. a1.sinks = k1
    4. a1.sources.r1.type=spooldir
    5. a1.sources.r1.spoolDir=/root/data/hbreal
    6. a1.sources.r1.fileHeader=true
    7. #a1.sinks.k1.type=logger
    8. a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
    9. a1.sinks.k1.kafka.topic = hbreal
    10. a1.sinks.k1.brokerList = s2:9092
    11. a1.sinks.k1.kafka.flumeBatchSize = 20
    12. a1.sinks.k1.kafka.producer.acks = 1
    13. a1.channels.c1.type=memory
    14. a1.sources.r1.channels=c1
    15. a1.sinks.k1.channel=c1

    选择file作为channel

    1. a1.channels.c1.type = file
    2. a1.channels.c1.checkpointDir = /root/flumedata/checkpoint
    3. a1.channels.c1.transactionCapacity = 1000000
    4. a1.channels.c1.dataDirs = /root/flumedata/data

    启动flume

    1. flume-ng agent -f ./flumeconfig/flume_spooldir.conf -n a1 -Dflume.root.logger=INFO,console