一、安装 JDK
该安装内容自行百度!
二、安装 Zookeeper
Windows 安装 ZooKeeper
三、安装 Kafka
1、下载
访问 官网 下载安装包
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-9-1024x786.png)
下载后进行解压,本文放置的是 D 盘根目录!
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-10-1024x663.png)
2、配置
进入 config 文件夹中,打开 server.properties
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-11-1024x580.png)
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-12-1024x580.png)
zookeeper.connect=localhost:2181
Zookeeper 端口默认 2181,如果按照 Zookeeper 时有更改过端口,则需要更改,否则无需理会
3、运行
进入 bin/windows 目录下,打开命令行,执行
.\kafka-server-start.bat ..\..\config\server.properties
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-14-1024x559.png)
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-15-1024x559.png)
4、测试
4.1、创建主题
在 bin/Windows 目录下,打开命令行,执行
.\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic LocalTest
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-16-1024x252.png)
可能是我下载的最新版的原因,已经不支持旧版本的某些指令,通过下方的内容可以看出:
参数 --zookeeper
已经更改为 --bootstrap-server
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-17-1024x805.png)
所以,使用以下指令创建主题:
.\kafka-topics.bat --create
--bootstrap-server
localhost:9092 --replication-factor 1 --partitions 1 --topic LocalTest
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-18-1024x84.png)
命令行可直接关闭!
4.2、打开生产者和消费者窗口
生产者
.\kafka-console-producer.bat --broker-list localhost:9092 --topic LocalTest
消费者
.\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic LocalTest
都执行后,在 kafka-console-producer.bat
的窗口中,输入你想要传输的内容。如果在 kafka-console-consumer.bat
窗口中正常显示则表示安装成功了!
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-19-1024x279.png)
5、可视化工具
访问 官网 下载对应系统的安装包
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-20-1024x842.png)
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-21-1024x95.png)
双击安装!
一直 Next 即可,本文安装在 D 盘根目录!
安装后打开,进行连接配置:
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-26-1024x576.png)
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-27-1024x576.png)
配置后,点击 Add 添加,然后进行连接,可以看到刚刚创建的 LocalTest 主题
![](https://cxiaoyu.cn/wp-content/uploads/2023/09/image-28-1024x576.png)
- 打赏
![](https://cxiaoyu.cn/wp-content/plugins/wzbaibaoxiang/images/wzt_chahao.png)
![](https://cxiaoyu.cn/wp-content/uploads/2023/06/微信二维码20230606.jpg)
![](https://cxiaoyu.cn/wp-content/uploads/2021/12/QQ二维码.png)
- 微信
- 支付宝