您如何彻底清除Apache Kafka?

时间:2018-10-23 08:48:46

标签: apache-kafka

我正在使用Apache Kafka进行消息传递的Spring Java微服务。有时我想完全重设我的Kafka集群(Zookeeper和代理),以便知道自己有一个干净的测试面板。但是,我的经纪人似乎仍然对应该删除的内容了解很多。

环境是Windows 10,我正在运行Cygwin的Kafka v2.12.2。

这是我当前重置Kafka设置的过程:

  1. 停止经纪人
  2. 停止Zookeeper
  3. 删除数据目录
  4. 重新启动Zookeeper
  5. 重新启动经纪人

这时,我看到代理日志记录了对加载偏移量和使用者组的引用。

例如:

[2018-10-23 09:38:49,118] INFO Replica loaded for partition __consumer_offsets-0 with initial high watermark 0 (kafka.cluster.Replica)
[2018-10-23 09:38:49,120] INFO [Partition __consumer_offsets-0 broker=0] __consumer_offsets-0 starts at Leader Epoch 0 from offset 0. Previous Leader Epoch was: -1 (kafka.cluster.Partition)

并且:

[2018-10-23 09:38:49,171] INFO Replica loaded for partition __consumer_offsets-23 with initial high watermark 0 (kafka.cluster.Replica)
[2018-10-23 09:38:49,172] INFO [Partition __consumer_offsets-23 broker=0] __consumer_offsets-23 starts at Leader Epoch 0 from offset 0. Previous Leader Epoch was: -1 (kafka.cluster.Partition)
[2018-10-23 09:38:49,174] INFO Replica loaded for partition __consumer_offsets-1 with initial high watermark 0 (kafka.cluster.Replica)
[2018-10-23 09:38:49,174] INFO [Partition __consumer_offsets-1 broker=0] __consumer_offsets-1 starts at Leader Epoch 0 from offset 0. Previous Leader Epoch was: -1 (kafka.cluster.Partition)

并且:

[2018-10-23 09:38:49,304] INFO [GroupMetadataManager brokerId=0] Scheduling loading of offsets and group metadata from __consumer_offsets-46 (kafka.coordinator.group.GroupMetadataManager)
[2018-10-23 09:38:49,304] INFO [GroupMetadataManager brokerId=0] Scheduling loading of offsets and group metadata from __consumer_offsets-49 (kafka.coordinator.group.GroupMetadataManager)
[2018-10-23 09:38:49,304] INFO [GroupMetadataManager brokerId=0] Scheduling loading of offsets and group metadata from __consumer_offsets-41 (kafka.coordinator.group.GroupMetadataManager)
[2018-10-23 09:38:49,305] INFO [GroupMetadataManager brokerId=0] Scheduling loading of offsets and group metadata from __consumer_offsets-44 (kafka.coordinator.group.GroupMetadataManager)
[2018-10-23 09:38:49,305] INFO [GroupMetadataManager brokerId=0] Scheduling loading of offsets and group metadata from __consumer_offsets-47 (kafka.coordinator.group.GroupMetadataManager)
[2018-10-23 09:38:49,305] INFO [GroupMetadataManager brokerId=0] Scheduling loading of offsets and group metadata from __consumer_offsets-1 (kafka.coordinator.group.GroupMetadataManager)
[2018-10-23 09:38:49,306] INFO [GroupMetadataManager brokerId=0] Scheduling loading of offsets and group metadata from __consumer_offsets-4 (kafka.coordinator.group.GroupMetadataManager)

编辑#1:

下面是我的属性文件中的几行。如果删除'C:\ tool \ kafka \ data',我仍然会看到与上面类似的日志记录。

zookeeper.properties

dataDir=C:/tools/kafka/data/zookeeper

server.properties

log.dirs=C:/tools/kafka/data/kafka-logs

1 个答案:

答案 0 :(得分:0)

结果是我仍然有一个进程连接到集群,这导致在集群启动后就重新构建偏移量。

确保110%的每个进程都已完成,并且删除数据目录的工作符合预期。