即使在卡夫卡机器重启后如何保持卡夫卡保留字节和卡夫卡保留段

how to remaine the kafka retentions-bytes and kafka retention-segment even after kafka machine reboot

我们为主题设置 retention bytes 值 - 104857600 - topic_test

[root@confluent01 ~]# kafka-topics --zookeeper localhost:2181 --alter --topic  topic_test --config retention.bytes=104857600
WARNING: Altering topic configuration from this script has been deprecated and may be removed in future releases.
         Going forward, please use kafka-configs.sh for this functionality
Updated config for topic "topic_test".

现在我们验证来自动物园管理员的retention bytes

[root@confluent01 ~]#  zookeeper-shell confluent01:2181 get /config/topics/topic_test
Connecting to confluent1:2181
{"version":1,"config":{"retention.bytes":"104857600"}}
cZxid = 0xb30a00000038

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
ctime = Mon Jun 29 11:42:30 GMT 2020
mZxid = 0xb31100008978
mtime = Wed Jul 22 19:22:20 GMT 2020
pZxid = 0xb30a00000038
cversion = 0
dataVersion = 7
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 54
numChildren = 0

现在我们对kafka confluent01机器执行reboot

机器启动和kafka服务成功启动后,我们再次检查来自zookeeper的retention-bytes

但是现在(机器重启后)我们可以看到 retention bytes 没有在 zookeeper

中配置
[root@confluent01 ~]#zookeeper-shell confluent01:2181 get /config/topics/topic_test
Connecting to confluent1:2181

WATCHER::

WatchedEvent state:SyncConnected type:None path:null  no retention bytes value 

{"version":1,"config":{}}
cZxid = 0xb30a00000038
ctime = Mon Jun 29 11:42:30 GMT 2020
mZxid = 0xb3110000779b
mtime = Wed Jul 22 14:09:19 GMT 2020
pZxid = 0xb30a00000038
cversion = 0
dataVersion = 2
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 25
numChildren = 0

问题是 - 即使在重启 kafka 机器后如何保持 retention bytes

注意 - 我们不想使用 server.properties 中的保留字节 因为我们为每个主题设置了不同的保留字节

Zookeeper 和 Kafka 默认将数据存储在 /tmp

如果您重新启动计算机,/tmp 将被清除

否则,如果您使用confluent start命令,这不是永久数据。

如果您使用 Docker/Kubernetes 而不安装任何卷,这也不是永久性的。


您还应该使用 kafka-topics --describe 命令而不是 zookeeper-shell,因为 Zookeeper 将在即将发布的 Kafka 版本中完全删除