1. 程式人生 > >flume+kafka+hdfs詳解

flume+kafka+hdfs詳解

utf-8 conf prop nts command format ext sink 1.4

flume架構圖

技術分享

單節點flume配置

flume-1.4.0 啟動flume

bin/flume-ng agent --conf ./conf  -f conf/flume-conf.properties -Dflume.root.logger=DEBUG,console -n agent

-n表示配置文件中agent的名字

[java] view plain copy
  1. agent.sources = r1
  2. agent.sinks = s1
  3. agent.channels = c1
  4. agent.sources.r1.channels = c1
  5. agent.sinks.s1.channel = c1
  6. #Describe/configure the sources
  7. agent.sources.r1.type = exec
  8. agent.sources.r1.command = tail -F /home/flume/loginfo
  9. #Use a channel which buffers events in memory
  10. agent.channels.c1.type = memory
  11. agent.channels.c1.capacity = 1000 #Event
  12. agent.channels.c1.transactionCapacity = 100
  13. agent.sinks.s1.type = logger

技術分享

技術分享

flume-1.4.0 + kafka-0.7.2+hdfs flume配置

[xml] view plain copy
  1. agent.sources = r1
  2. agent.sinks = s_kafka s_hdfs
  3. agent.channels = c_kafka c_hdfs
  4. agent.sources.r1.channels = c_kafka c_hdfs
  5. agent.sources.r1.type = exec
  6. #下面這個腳本tail某個日誌
  7. agent.sources.r1.command = tail -F /home/flume/loginfo
  8. agent.channels.c_kafka.type = memory
  9. agent.channels.c_hdfs.type = memory
  10. agent.sinks.s_kafka.type = com.sink.FirstkafkaSink
  11. agent.sinks.s_kafka.channel = c_kafka
  12. #kafka需要連接zk,寫入broker數據
  13. agent.sinks.s_kafka.zkconnect = localhost:2181
  14. agent.sinks.s_kafka.topic = test
  15. agent.sinks.s_kafka.serializer.class = kafka.serializer.StringEncoder
  16. agent.sinks.s_kafka.metadata.broker.list = localhost:9092 #配置文件server.properties
  17. agent.sinks.s_kafka.custom.encoding = UTF-8
  18. agent.sinks.s_hdfs.type = hdfs
  19. agent.sinks.s_hdfs.channel = c_hdfs
  20. #默認端口8020
  21. agent.sinks.s_hdfs.hdfs.path = hdfs://localhost:9000/root/source
  22. agent.sinks.s_hdfs.hdfs.filePrefix = events-
  23. agent.sinks.s_hdfs.hdfs.fileType = DataStream
  24. agent.sinks.s_hdfs.hdfs.writeFormat = Text
  25. agent.sinks.s_hdfs.hdfs.rollCount = 30 #達到某一數值記錄生成文件
  26. agent.sinks.s_hdfs.hdfs.rollSize = 0
  27. agent.sinks.s_hdfs.hdfs.rollInterval = 0
  28. agent.sinks.s_hdfs.hdfs.useLocalTimeStamp = true
  29. agent.sinks.s_hdfs.hdfs.idleTimeout = 51
  30. agent.sinks.s_hdfs.hdfs.threadsPoolSize = 2

Flume內置channel,source,sink匯總

http://www.iteblog.com/archives/948

本文出自 “點滴積累” 博客,請務必保留此出處http://tianxingzhe.blog.51cto.com/3390077/1700049

flume+kafka+hdfs詳解