[关闭]
@rickyChen 2018-07-25T16:13:20.000000Z 字数 1462 阅读 2264

Flume 1.8.0读取Kafka写HDFS

Flume


环境准备

安装Flume

  1. wget http://mirrors.tuna.tsinghua.edu.cn/apache/flume/1.8.0/apache-flume-1.8.0-bin.tar.gz
  2. tar -xvf apache-flume-1.8.0-bin.tar.gz

下载Hadoop依赖

从Hadoop集群中获取相关jar包放到flume/lib文件夹下

  1. hadoop-common-2.6.3.jar
  2. hadoop-hdfs-2.6.3.jar
  3. commons-configuration-1.6.jar
  4. hadoop-auth-2.6.3.jar
  5. htrace-core-3.0.4.jar

DEMO

  1. # example.conf: A single-node Flume configuration
  2. # Name the components on this agent
  3. a1.sources = r1
  4. a1.sinks = k1
  5. a1.channels = c1
  6. # Describe/configure the source
  7. a1.sources.r1.type = org.apache.flume.source.kafka.KafkaSource
  8. a1.sources.r1.kafka.bootstrap.servers = localhost:9092
  9. a1.sources.r1.kafka.consumer.group.id = flume_test
  10. a1.sources.r1.kafka.topics = flume_topic
  11. # Describe the sink
  12. a1.sinks.k1.type = hdfs
  13. a1.sinks.k1.hdfs.path = hdfs://localhost:8020/rawlog/20%y-%m-%d/%H
  14. a1.sinks.k1.hdfs.useLocalTimeStamp = false
  15. a1.sinks.k1.hdfs.writeFormat = Text
  16. a1.sinks.k1.hdfs.filePrefix = test
  17. a1.sinks.k1.hdfs.fileType = DataStream
  18. a1.sinks.k1.hdfs.rollInterval = 3600
  19. a1.sinks.k1.hdfs.rollSize = 12800000000
  20. a1.sinks.k1.hdfs.rollCount = 0
  21. a1.sinks.k1.hdfs.threadsPoolSize = 10
  22. a1.sinks.k1.hdfs.batchSize = 2000
  23. a1.sinks.k1.hdfs.threadsPoolSize = 10
  24. # Use a channel which buffers events in memory
  25. a1.channels.c1.type = memory
  26. a1.channels.c1.capacity = 1500000
  27. a1.channels.c1.transactionCapacity = 10000
  28. # Bind the source and sink to the channel
  29. a1.sources.r1.channels = c1
  30. a1.sinks.k1.channel = c1

运行命令

  1. ./bin/flume-ng agent --conf conf --conf-file ./conf/example.conf --name a1 -Dflume.root.logger=INFO,console
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注