Kafka安装及zookeeper is not a recognized option问题解决

Posted playwrighter

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Kafka安装及zookeeper is not a recognized option问题解决相关的知识,希望对你有一定的参考价值。

一安装JAVA JDK(略)

二安装ZooKeeper

下载安装包,建议bin版本

http://zookeeper.apache.org/releases.html#download

解压并进入ZooKeeper,将“zoo_sample.cfg”重命名为“zoo.cfg”

D:\\Kafka\\apache-zookeeper-3.7.1-bin\\conf

打开“zoo.cfg”并编辑

dataDir=D:\\\\Kafka\\\\apache-zookeeper-3.7.1-bin\\\\data 
dataLogDir=D:\\\\Kafka\\\\apache-zookeeper-3.7.1-bin\\\\log

添加系统变量:ZOOKEEPER_HOME=D:\\Kafka\\apache-zookeeper-3.7.1-bin编辑path系统变量:%ZOOKEEPER_HOME%\\bin

打开新的cmd,输入“zkServer“,运行Zookeeper

本地Zookeeper启动成功

问题:ZooKeeper audit is disabled.

解决方法:在zoo.cfg中添加

audit.enabled = true

三安装Kafka

下载安装包,建议下载bin版本

http://kafka.apache.org/downloads

解压并进入Kafka编辑server.properties

D:\\Kafka\\kafka_2.13-3.3.2\\config

编辑log.dirs=D:/Kafka/kafka_2.13-3.3.2/kafka-logs

选择“打开命令窗口”选项,D:/Kafka/kafka_2.13-3.3.2下,输入:

.\\bin\\windows\\kafka-server-start.bat .\\config\\server.properties

创建topic

.\\bin\\windows\\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

查看topic

.\\bin\\windows\\kafka-topics.bat --list --zookeeper localhost:2181

生产者往topic中发消息

.\\bin\\windows\\kafka-console-producer.bat --broker-list localhost:9092 --topic test

消费者

.\\bin\\windows\\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning

问题:zookeeper is not a recognized option(版本原因)

解决方法:zookeeper改bootstrap-server

启动kafka

.\\bin\\windows\\kafka-server-start.bat config\\server.properties

创建topic

.\\bin\\windows\\kafka-topics.bat --create --topic topic-test --bootstrap-server localhost:9092

生产者往topic中发消息

.\\bin\\windows\\kafka-console-producer.bat --topic topic-test --bootstrap-server localhost:9092

消费者接受消息

.\\bin\\windows\\kafka-console-consumer.bat --topic topic-test --bootstrap-server localhost:9092

以上是关于Kafka安装及zookeeper is not a recognized option问题解决的主要内容,如果未能解决你的问题,请参考以下文章

kafka 创建消费者报错 consumer zookeeper is not a recognized option

kafka报错:Exception in thread “main“ joptsimple.UnrecognizedOptionException: zookeeper is not a recogn

kafka报错:Exception in thread “main“ joptsimple.UnrecognizedOptionException: zookeeper is not a recogn

zookeeper环境搭建中的几个坑[Error contacting service. It is probably not running]的分析及解决

Zookeeper群起脚本启动失败及查看状态出现:Error contacting service. It is probably not running

Kafka分布式安装及验证测试