关于您在“kafka系列解读-文档”的帖子
楼主你好,看了你的文档我试了一下,报了一个错误 ,能告诉我这是为什么吗
[root@test-90 kafka_2.9.1-0.8.2.1]# bin/kafka-console-producer.sh --zookeeper 192.168.89.90:2181 --topic test
Exception in thread "main" joptsimple.UnrecognizedOptionException: 'zookeeper' is not a recognized option
at joptsimple.OptionException.unrecognizedOption(OptionException.java:93)
at joptsimple.OptionParser.handleLongOptionToken(OptionParser.java:402)
at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:55)
at joptsimple.OptionParser.parse(OptionParser.java:392)
at kafka.tools.ConsoleProducer$ProducerConfig.<init>(ConsoleProducer.scala:216)
at kafka.tools.ConsoleProducer$.main(ConsoleProducer.scala:35)
at kafka.tools.ConsoleProducer.main(ConsoleProducer.scala)
[root@test-90 kafka_2.9.1-0.8.2.1]#
答案:【一网友问的,这里给出答案】
消费者才有zookeeper
Kafka提供了一个命令行的工具,可以从输入文件或者命令行中读取消息并发送给Kafka集群。每一行是一条消息。
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
This is a message
This is another message
Kafka也提供了一个消费消息的命令行工具。
> bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
This is a message
This is another message