如何在kafka consumer中检查file.txt的输出?

efzxgjgh  于 2021-06-08  发布在  Kafka
关注(0)|答案(1)|浏览(363)

我正在尝试将flume与kafka集成,我想将一个文件从本地计算机传递到flume,然后再传递到kafka。我想看看Kafka消费者中我文件的内容。
这是我在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的内容。请给我建议。谢谢。

kh212irz

kh212irz1#

因为kafka是一个消息代理“服务”,所以在使用flume生产者生成消息之前必须运行它。在生产者生成(放入)一条消息到一个Kafka主题(一种缓冲区)之后,您可以与一个Kafka使用者一起使用(获取)该消息。
如何启动Kafka服务:http://kafka.apache.org/documentation.html#quickstart

相关问题