【问题标题】:How to check the output of file.txt in Kafka Consumer?如何检查 Kafka Consumer 中 file.txt 的输出?
【发布时间】:2015-11-04 06:02:29
【问题描述】:

我正在尝试将 Flume 与 Kafka 集成,我想将文件从本地机器传递到 Flume,然后再传递到 Kafka。我想在 Kafka Consumer 中查看我的文件内容。

这是我在 Flume 中的配置文件:

# example.conf: A single-node Flume configuration

 # Name the components on this agent
 a1.sources = r1
 a1.sinks = k1
 a1.channels = c1

 # Describe/configure the source
 a1.sources.r1.type = exec
 a1.sources.r1.command = cat /Users/myname/Downloads/file.txt

 # Describe the sink
 #a1.sinks.k1.type = logger
  a1.sinks.k1.type         = org.apache.flume.sink.kafka.KafkaSink
  a1.sinks.k1.topic = k1
  a1.sinks.k1.brokerList = kafkagames-1:9092,kafkagames-2:9092
  a1.sinks.sink1.batchSize = 20

  # Use a channel which buffers events in memory
  a1.channels.c1.type = memory
  a1.channels.c1.capacity = 10000
  a1.channels.c1.transactionCapacity = 10000

  # Bind the source and sink to the channel
  a1.sources.r1.channels = c1
  a1.sinks.k1.channel = c1

我不知道如何从 Flume 启动 Kafka 并在 Kafka Consumer 中查看 file.txt 的内容。请指教。谢谢。

【问题讨论】:

    标签: file-upload apache-kafka flume-ng


    【解决方案1】:

    由于 Kafka 是一个消息代理“服务”,因此您必须在使用 Flume 生产者生成消息之前运行它。生产者生成(放置)消息到 Kafka 主题(一种缓冲区)后,您可以使用 Kafka 消费者来消费(获取)消息。

    如何启动Kafka服务: http://kafka.apache.org/documentation.html#quickstart

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-02
      • 2020-07-27
      • 1970-01-01
      • 2019-10-01
      • 2016-12-10
      • 2015-08-31
      • 2017-03-27
      相关资源
      最近更新 更多