当前位置:   article > 正文

windows下kafka命令总结_windows kafka 消费者指令

windows kafka 消费者指令

kafka安装可参考这一篇博客https://blog.csdn.net/github_38482082/article/details/82112641

我安装的是kafka_2.11-2.3.1,要注意实际写代码中服务器和idea客户端的中maven版本要对应
2.3.x对应于kafka-clients 2.3.1

进入
kafka的安装目录,对我是E:\install\kafka_2.11-2.3.1 ,在目录的搜索里面输入cmd,回车,进入cmd就可使用以下kafka指令

 

1)启动kafka内置的zookeeper,不关闭页面
.\bin\windows\zookeeper-server-start.bat  .\config\zookeeper.properties

2)kafka服务启动 ,不关闭页面
.\bin\windows\kafka-server-start.bat .\config\server.properties

3)创建topic测试主题kafka,成功不关闭页面
.\bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

4)创建生产者产生消息,不关闭页面
.\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test

5)创建消费者接收消息,不关闭页面
.\bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning

1、查询topic,进入kafka目录:
.\bin\windows\kafka-topics.bat --list --zookeeper localhost:2181
 
2、查询topic配置信息:
.\bin\windows\kafka-topics.bat --describe --zookeeper localhost:2181 --topic topicname
可以显示

Topic:topic1    PartitionCount:1        ReplicationFactor:1     Configs:
        Topic: topic1   Partition: 0    Leader: 0       Replicas: 0     Isr: 0

3、查询topic内容:

 

4、删除topic:
.\bin\windows\kafka-topics.bat kafka.admin.DeleteTopicCommand --zookeeper localhost:2181 --delete --topic linlin
显示marked for deletion
这个命令最好千万不要使用,否则处理不好的话kafka服务就启动不了了,而且不能真正删掉topic,看了一些博客,貌似真的想要删除一个topic还是比较麻烦的。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/400278
推荐阅读
相关标签
  

闽ICP备14008679号