已解决
Kafka3.x安装以及使用
来自网友在路上 163863提问 提问时间:2023-10-25 01:41:06阅读次数: 63
最佳答案 问答题库638位专家为你答疑解惑
一、Kafka下载
下载地址:https://kafka.apache.org/downloads
二、Kafka安装
因为选择下载的是 .zip 文件,直接跳过安装,一步到位。
选择在任一磁盘创建空文件夹(不要使用中文路径),解压之后把文件夹内容剪切进去(本人选择 D:\env-java\路径下,即完成安装)。
linux解压命令tar -zxvf kafka_2.13-3.5.1.tgz
,linux环境下指令是在\kafka_2.13-3.5.1\bin
目录。
windows直接解压即可,windows环境下指令是在kafka_2.13-3.5.1\bin\windows
目录。
注意:不同系统指令所在的目录不同。
执行命令当前目录D:\env-java\kafka_2.13-3.5.1
修改 kafka-server 和zookeeper配置
进入到目录:kafka_2.13-3.5.1/config/server.properties
以及kafka_2.13-3.5.1/config/zookeeper.properties
- linux系统:
broker.id=1
log.dir=/Users/imagetask/kafka-logs
- windows系统:
broker.id=1
log.dirs=/env-java/kafka_2.13-3.5.1/kafka-logs
/:表示当前的根路径,即D盘。没有就会创建对应的文件夹。
三、启动Kafka服务
1、启动ZooKeeper
- linux系统:
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
- windows系统:
bin\windows\zookeeper-server-start.bat config\zookeeper.properties
2、启动kafka
- linux系统:
bin/kafka-server-start.sh config/server.properties
- windows系统:
bin\windows\kafka-server-start.bat config\server.properties
四、Kafka的使用
1、创建主题
- linux系统:
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
- windows系统:
bin\windows\kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
2、删除主题
- linux系统:
bin/kafka-topics.sh --delete --bootstrap-server localhost:9092 --topic test
- windows系统:
bin\windows\kafka-topics.bat --delete --bootstrap-server localhost:9092 --topic test
3、查看Topic 列表
- linux系统:
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
- windows系统:
bin\windows\kafka-topics.bat --list --bootstrap-server localhost:9092
4、启动 Producer
- linux系统:
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
- windows系统:
bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test
5、启动 Consumer
- linux系统:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
- windows系统:
bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning
6、查看Topic 相关信息(test)
- linux系统:
bin/kafka-topics.sh --describe --bootstrap-server localhost:9092 --topic test
- windows系统:
bin\windows\kafka-topics.bat --describe --bootstrap-server localhost:9092 --topic test
查看全文
99%的人还看了
相似问题
- 基于ASP.NET MVC技术的图书管理系统的设计与实现
- MySQL数据库:开源且强大的关系型数据库管理系统
- 最新AIGC创作系统ChatGPT系统源码,支持最新GPT-4-Turbo模型,支持DALL-E3文生图,图片对话理解功能
- 基于springboot实现班级综合测评管理系统项目【项目源码+论文说明】
- 香港科技大学广州|机器人与自主系统学域博士招生宣讲会—同济大学专场!!!(暨全额奖学金政策)
- 合肥中科深谷嵌入式项目实战——基于ARM语音识别的智能家居系统(三)
- 基于Springboot的美容院管理系统(有报告)。Javaee项目,springboot项目。
- MES系统管理范围及标准
- 性能测试:系统架构性能优化思路
- django+drf+vue 简单系统搭建 (3) - 基于类的视图
猜你感兴趣
版权申明
本文"Kafka3.x安装以及使用":http://eshow365.cn/6-23776-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!