如何从 zookeeper 元数据中捕获保留字节值

how to capture the retention bytes values from zookeeper meta data

我们正在尝试从主题中获取 retention bytes 值 - topic_test

我们尝试以下示例,但似乎这不是来自 zookeeper 的正确路径

zookeeper-shell kafka1:2181,kafka2:2181,kafka3:2181 <<< "ls /brokers/topics/topic_test/partitions/88/state"
Connecting to kafka1:2181,kafka2:2181,kafka3:2181
Welcome to ZooKeeper!
JLine support is disabled

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[]

知道可以从 zookeeper 捕获的每个主题 retention byte 的值在哪里吗?

我做了以下操作,但没有看到保留字节(这里有什么问题),我们有 kafka 融合 version - 0.1

zookeeper-shell confluent1:2181 get /config/topics/test_topic
Connecting to kafka1:2181

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
{"version":1,"config":{}}
cZxid = 0xb30a00000038
ctime = Mon Jun 29 11:42:30 GMT 2020
mZxid = 0xb30a00000038
mtime = Mon Jun 29 11:42:30 GMT 2020
pZxid = 0xb30a00000038
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 25
numChildren = 0

配置存储在 /config 路径下的 Zookeeper 中。

例如,对于主题topic_test

# Create topic
./bin/kafka-topics.sh --bootstrap-server localhost:9092 --create \
    --topic topic_test --partitions 1 --replication-factor 1 --config retention.bytes=12345

# Retrieve configs from Zookeeper
./bin/zookeeper-shell.sh localhost get /config/topics/topic_test
Connecting to localhost

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
{"version":1,"config":{"retention.bytes":"12345"}}

请注意,在大多数情况下,您不应依赖直接访问 Zookeeper,而是使用 Kafka API 来检索这些值。

使用:

  • kafka-topics.sh:

    ./bin/kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic topic_test
    
  • kafka-configs.sh:

    ./bin/kafka-configs.sh --bootstrap-server localhost:9092 --describe --entity-type topics --entity-name topic_test
    
  • 管理员 API 使用 describeConfigs()