windows 下对Kafka主题的部分命令

来源:互联网 发布:双色球缩水定位软件 编辑:程序博客网 时间:2024/06/10 02:09

dos下启动Kafka(版本kafka_2.11-0.10.0.0):

cd Java\kafka_2.11-0.10.0.0

Java\kafka_2.11-0.10.0.0>.\bin\windows\kafka-server-start.bat .\config\server.properties

windows 下查看主题
D:\Java\kafka_2.11-0.10.0.0\bin\windows>kafka-topics.bat --describe --zookeeper localhost:2181 --topic     business_log(主题的名字)

查看主题的content

D:\Java\kafka_2.11-0.10.0.0\bin\windows>kafka-console-consumer.bat --zookeeper localhost:2181 --from-beginning --topic business_log(主题的名字)


往主题写入消息
kafka-console-producer.bat --broker-list localhost:9092 --topic business_log

创建一个主题:

bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic business_log(主题的名字)

查看所有创建的主题列表:

bin\windows\kafka-topics.bat --list --zookeeper localhost:2181

彻底删除本机kafka的topic

   1.server.properties 中添加delete.topic.enable=true

   2.执行D:\Developer\kafka_2.10-0.10.0.0\bin\windows>kafka-topics.bat --zookeeper 127.0.0.1(本机的IP):2181 --delete --topic business_log(主题的名字)

  3. 执行zookeeper-server-stop.bat,重启kafka

若是重新发送消息,会自动根据配置的partitions重建。

注意:不执行1步骤,就是假删除