事情起因是这样的。我们环境需要用到kafka,现在都是使用容器化的部署,大佬就找了个github星最多docker-kafka连接给我,建议我用这个来搭建。我们开发环境已经有了zk,所以就让我用kafka连上面的zk。kafka搭起来了,生产者可以生产。但是消费者始终是消费不到消息。使用tcpdump抓包也可以确认,消息已经发送到kafka。但是消费者始终无法消费。猜想是不是那个步骤执行错了。所以就按照https://github.com/wurstmeister/kafka-docker的官方文档一步一步来做。
wurstmeister docker-kafka tutorial:http://wurstmeister.github.io/kafka-docker/
发现里面有一步骤怎么也走不通:
$KAFKA_HOME/bin/kafka-console-consumer.sh --topic=topic --zookeeper=$ZK
本地查看脚本的帮助,也没有这个参数,类似功能的是--bootstrap-server
的参数:
D:\Programs\kafka_2.11-2.4.0\bin\windows>kafka-console-consumer.bat --help
This tool helps to read data from Kafka topics and outputs it to standard output
.
Option Description
------ -----------
--bootstrap-server <String: server to REQUIRED: The server(s) to connect to.
connect to>
--consumer-property <String: A mechanism to pass user-defined
consumer_prop> properties in the form key=value to
the consumer.
--consumer.config <String: config file> Consumer config properties file. Note
that [consumer-property] takes
precedence over this config.
--enable-systest-events Log lifecycle events of the consumer
in addition to logging consumed
messages. (This is specific for
system tests.)
--formatter <