kafka的官方下载路径
https://www.apache.org/dyn/closer.cgi?path=/kafka/3.1.0/kafka_2.13-3.1.0.tgz
解压到D盘路径:D:\kafka\kafka_2.13-3.1.0
进入config目录找到文件server.properties并打开
找到并编辑log.dirs改为:
进入config目录找到文件zookeeper.properties并打开
找到并编辑dataDir改为
在kafka安装目录:按下Shift+右键,选择“打开命令窗口”选项,打开命令行,输入:
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
先启动:
.\bin\windows\kafka-server-start.bat .\config\server.properties
在启动:
最后创建主题:
.\bin\windows\kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic ams
删除主题
.\bin\windows\kafka-topics.bat --delete --bootstrap-server localhost:9092 --topic ams
在较新版本(2.2 及以上版本)的 Kafka 不再需要 ZooKeeper 连接字符串,即- -zookeeper localhost:2181。使用 Kafka Broker的 --bootstrap-server localhost:9092来替代- -zookeeper localhost:2181。