Apache kafka 在Windows上删除卡夫卡主题内数据的步骤?

Apache kafka 在Windows上删除卡夫卡主题内数据的步骤?,apache-kafka,Apache Kafka,我正在研究SpringBatch和ApacheKafka集成。在发布这个问题之前,我浏览了网页:寻找更好的解决方案,但没有找到 我使用的是卡夫卡2.11版 我想在不停止Zookeeper或Kafka的情况下删除主题下的所有数据。我们怎么能做到呢 下面的命令在windows中会导致很多问题 C:\kafka_2.11-2.3.1\bin\windows>kafka-topics.bat --zookeeper localhost:2181 --delete --topic customers

我正在研究SpringBatch和ApacheKafka集成。在发布这个问题之前,我浏览了网页:寻找更好的解决方案,但没有找到

我使用的是卡夫卡2.11版

我想在不停止Zookeeper或Kafka的情况下删除主题下的所有数据。我们怎么能做到呢

下面的命令在windows中会导致很多问题

C:\kafka_2.11-2.3.1\bin\windows>kafka-topics.bat --zookeeper localhost:2181 --delete --topic customers
Topic customers is marked for deletion.
Note: This will have no impact if delete.topic.enable is not set to true.

C:\kafka_2.11-2.3.1\bin\windows>kafka-topics.bat --zookeeper localhost:2181 --delete --topic test

C:\kafka_2.11-2.3.1\bin\windows>kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic customers --from-beginning
[2020-04-21 10:25:02,812] WARN [Consumer clientId=consumer-1, groupId=console-consumer-65075] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2020-04-21 10:25:04,886] WARN [Consumer clientId=consumer-1, groupId=console-consumer-65075] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2020-04-21 10:25:06,996] WARN [Consumer clientId=consumer-1, groupId=console-consumer-65075] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2020-04-21 10:25:09,267] WARN [Consumer clientId=consumer-1, groupId=console-consumer-65075] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2020-04-21 10:25:11,744] WARN [Consumer clientId=consumer-1, groupId=console-consumer-65075] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
Processed a total of 0 messages
Terminate batch job (Y/N)?
^C
C:\kafka_2.11-2.3.1\bin\windows>
我使用的是卡夫卡2.11版

没有卡夫卡2.11。您的命令提示符显示
kafka_2.11-2.3.1
:因此,您使用的是kafka 2.3.1。2.11部分是编译期间使用的Scala版本

注意:如果delete.topic.enable未设置为true,则这不会产生任何影响


如果
delete.topic.enable
设置为
true
,是否检查代理配置?如果是,您应该能够在不停止ZK或代理的情况下删除主题。但是请注意,删除主题是异步的,也就是说,当您的命令返回时,主题尚未被删除,并且在执行该命令之前需要一些时间。

您是否考虑过将
retention.ms
更改为1,然后按照发布的链接中的建议恢复正常?