当前位置:   article > 正文

flume 实时读取本地文件到kafka_windows系统flume读取文件传到kafka

windows系统flume读取文件传到kafka

本文写的比较简单,因为都大同小异,如果忘记flume的使用和语法等,可以看下如下文章,回顾下
flume 实时读取本地文件到hdfs
https://blog.csdn.net/qq_41712271/article/details/103939224

  1. #Name the components on this agent
  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1
  5. # Describe/configure the source
  6. a1.sources.r1.type = exec
  7. a1.sources.r1.command = tail -F /opt/test.log
  8. a1.sources.r1.shell = /bin/bash -c
  9. # kafka sink
  10. a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
  11. a1.sinks.k1.kafka.topic = topic-1
  12. a1.sinks.k1.kafka.bootstrap.servers = cdh001:9092,cdh002:9092,cdh003:9092
  13. # 一批中要处理多少条消息。较大的批次可提高吞吐量,同时增加延迟。
  14. a1.sinks.k1.kafka.flumeBatchSize = 6000
  15. a1.sinks.k1.kafka.producer.acks = 1
  16. a1.sinks.k1.kafka.producer.linger.ms = 1
  17. a1.sinks.ki.kafka.producer.compression.type = snappy
  18. # Use a channel which buffers events in memory
  19. a1.channels.c1.type = memory
  20. a1.channels.c1.capacity = 1000
  21. a1.channels.c1.transactionCapacity = 100
  22. # Bind the source and sink to the channel
  23. a1.sources.r1.channels = c1
  24. a1.sinks.k1.channel = c1

运行flume
./bin/flume-ng agent -c conf/ -f /usr/local/txt_kafka.conf -n a1

测试,往文件中追加记录,运行kafka的消费端,查看消费的情况
echo $(date "+%Y-%m-%d %H:%M:%S") >> /opt/test.log
./kafka-console-consumer.sh --bootstrap-server cdh001:9092,cdh002:9092,cdh003:9092 --from-beginning --topic topic-1

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/秋刀鱼在做梦/article/detail/936730
推荐阅读
相关标签
  

闽ICP备14008679号