方式二:官网下载:https://zookeeper.apache.org/releases.html
这里下载编译好的
下载后进行解压
添加系统变量 ZOOKEEPER_HOME,值为自己下载的zookeeper的路径,
如我的 D:\env\apache-zookeeper-3.7.1-bin\apache-zookeeper-3.7.1-bin\conf
D:\kafka\zookeeper-3.7.1\apache-zookeeper-3.7.1-bin\conf
编辑path变量,添加 %ZOOKEEPER_HOME%\bin
因为Kafka中的Broker注册,Topic注册,以及负载均衡都是在Zookeeper中管理,
所以需要先启动内置的Zookeeper.
进入 Zookeeper解压目录D:\kafka\zookeeper-3.7.1\apache-zookeeper-3.7.1-bin\bin
双击:zkServer.cmd 启动 Zookeeper.
或者
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
当看到绑定到IP地址为0.0.0.0、端口号为2181的地址,表示ZooKeeper服务器监听在该地址,启动成功。
该窗口不要关闭!!!
方式二:官网下载 https://kafka.apache.org/downloads
https://downloads.apache.org/kafka/3.5.1/kafka_2.12-3.5.1.tgz
所以kafka2.11-2.4.0是不需要安装Zookeeper的,直接解压即可。
解压后将文件夹名称改为kafka,名称不能太长,否则后面启动的时候会出现错误
log.dirs=D:\kafka\kafkaLogs
zookeeper.connect=localhost:2181
listeners=PLAINTEXT://localhost:9092
Zookeeper.properties
maxClientCnxns=50
不配置或配置错误会提示:
查看Kafka集群下所有的topic报错:
“Timed out waiting for a node assignment. Call: listTopics“
https://blog.csdn.net/cnds123321/article/details/124079002
kafka集群启动报错Error creating broker listeners from 'PLAINTEXT:
https://blog.csdn.net/qq_14905699/article/details/129788752
执行:.\bin\windows\kafka-server-start.bat .\config\server.properties
启动报错: Will not attempt to authenticate using SASL (unknown error)
处理方法:关闭防火墙
之后该命令行不要关闭。
.\bin\windows\kafka-topics.bat
–create
–zookeeper localhost:2181
–replication-factor 1
–partitions 1
–topic test
进入kafka 解压目录D:\kafka\kafka_2.10-0.9.0.0,cmd:
// 2.2版本及以上使用–bootstrap-server代替–zookeeper
.\bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
Kafka报错:Exception in thread “main“ joptsimple.UnrecognizedOptionException:zookeeper is not a recogn
https://blog.csdn.net/succing/article/details/127334561
解决zookeeper is not a recognized option问题
https://blog.csdn.net/weixin_43857576/article/details/121659791
Kafka常用命令
https://blog.csdn.net/csdn_lan/article/details/128899245
.\bin\windows\kafka-topics.bat --list --zookeeper localhost:2181
.\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
.\bin\windows\kafka-topics.bat --delete --zookeeper localhost:2181 --topic test
可以发现是逻辑删除,并不是先直接物理删除的
删除后重新查询列表
.\bin\windows\kafka-topics.bat --list --zookeeper localhost:2181
重新创建topic 发现topic : test 没有被真正的删除(非物理删除,只是逻辑删除)
问题
ERROR Shutdown broker because all log dirs in D:\env\kafka\kafka\logs have failed (kafka.log.LogManager)
解决办法: 1.去kafka日志目录下删除log里topic日志(重启kafka还是报错)。 2. 还需要删除zookeeper里zoo.cfg里配置的dataDir目录下的日志。
启动时提示,输入行太长。命令语法不正确
方式一: 文件名称太长,将其直接改为kafka
方式二:https://blog.csdn.net/FunnyWhiteCat/article/details/126241088
官网下载: https://www.kafkatool.com/download.html