执行 kafka-console-consumer.sh 时,zookeeper 不是可识别的选项
zookeeper is not a recognized option when executing kafka-console-consumer.sh
我正在学习如何在这个网站上使用 Kafka link(除了我在 zookeeper 中使用端口 2182),但它显示:
zookeeper is not a recognized option
执行后:
sudo ./bin/kafka-console-consumer.sh --topic test --zookeeper
localhost:2182
如何解决?
环境:
kafka_2.11-2.1.0
zookeeper-3.4.10
我在 QUICKSTART 上找到了答案:
Option zookeeper
is deprecated, use --bootstrap-server
instead.
现在可以使用了:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
windows 用户使用
bin/kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning
对于windows
启动zookeeper
C:\kafka-2.12>.\bin\windows\zookeeper-server-start.bat .\config\server.properties
启动Kafka Broker
C:\kafka-2.12>.\bin\windows\kafka-server-start.bat .\config\server.properties
创建主题
C:\kafka-2.12\bin\windows>kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
启动制作人
C:\kafka-2.12\bin\windows>kafka-console-producer.bat --broker-list localhost:9092 --topic test
创建消费者
C:\kafka-2.12\bin\windows>kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning
使用复制因子为 1 的多分区创建主题
C:\kafka-2.12\bin\windows>kafka-topics --zookeeper localhost:2181 --topic first_topic --create --partitions 3 --replication-factor 1
获取系统创建的主题列表
C:\kafka-2.12\bin\windows>kafka-topics --zookeeper localhost:2181 --list
获取系统创建主题的描述
C:\kafka-2.12\bin\windows>kafka-topics.bat --describe --zookeeper localhost:2181 --topic test
删除系统中创建的主题test
C:\kafka-2.12\bin\windows>kafka-run-class.bat kafka.admin.TopicCommand --delete --topic test --zookeeper localhost:2181
从系统(版本>2.0)中创建的主题测试开始阅读消息
C:\kafka-2.12\bin\windows>kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginn
更新
- 从2.1.*版本开始,以前的答案可能不成立,经常查看官方documentation,此答案随版本
3.1.0
提供。
对于 Linux 内核基础系统
./kafka-topics.sh --create --topic yourTopicname --bootstrap-server localhost:9092
对于 Windows 个系统
./kafka-topics.bat --create --topic quickstart-events --bootstrap-server localhost:9092
当没有初始偏移量时无需传递 --from-beginning
并使用所需的 configs
重载创建命令
我正在学习如何在这个网站上使用 Kafka link(除了我在 zookeeper 中使用端口 2182),但它显示:
zookeeper is not a recognized option
执行后:
sudo ./bin/kafka-console-consumer.sh --topic test --zookeeper localhost:2182
如何解决?
环境:
kafka_2.11-2.1.0
zookeeper-3.4.10
我在 QUICKSTART 上找到了答案:
Option
zookeeper
is deprecated, use--bootstrap-server
instead.
现在可以使用了:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
windows 用户使用
bin/kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning
对于windows
启动zookeeper
C:\kafka-2.12>.\bin\windows\zookeeper-server-start.bat .\config\server.properties
启动Kafka Broker
C:\kafka-2.12>.\bin\windows\kafka-server-start.bat .\config\server.properties
创建主题
C:\kafka-2.12\bin\windows>kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
启动制作人
C:\kafka-2.12\bin\windows>kafka-console-producer.bat --broker-list localhost:9092 --topic test
创建消费者
C:\kafka-2.12\bin\windows>kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning
使用复制因子为 1 的多分区创建主题
C:\kafka-2.12\bin\windows>kafka-topics --zookeeper localhost:2181 --topic first_topic --create --partitions 3 --replication-factor 1
获取系统创建的主题列表
C:\kafka-2.12\bin\windows>kafka-topics --zookeeper localhost:2181 --list
获取系统创建主题的描述
C:\kafka-2.12\bin\windows>kafka-topics.bat --describe --zookeeper localhost:2181 --topic test
删除系统中创建的主题test
C:\kafka-2.12\bin\windows>kafka-run-class.bat kafka.admin.TopicCommand --delete --topic test --zookeeper localhost:2181
从系统(版本>2.0)中创建的主题测试开始阅读消息
C:\kafka-2.12\bin\windows>kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginn
更新
- 从2.1.*版本开始,以前的答案可能不成立,经常查看官方documentation,此答案随版本
3.1.0
提供。
对于 Linux 内核基础系统
./kafka-topics.sh --create --topic yourTopicname --bootstrap-server localhost:9092
对于 Windows 个系统
./kafka-topics.bat --create --topic quickstart-events --bootstrap-server localhost:9092
当没有初始偏移量时无需传递 --from-beginning
并使用所需的 configs