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



我们正试图从主题topic_test 中捕获retention bytes

我们尝试了下面的例子,但这似乎不是动物园管理员的正确路径

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
[]

你知道动物园管理员可以捕捉到的每个主题的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

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

例如,对于主题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
    
  • 使用describeConfigs() 的管理员API

最新更新