Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache kafka 如何从zookeeper元数据中捕获保留字节值_Apache Kafka_Apache Zookeeper - Fatal编程技术网

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

Apache kafka 如何从zookeeper元数据中捕获保留字节值,apache-kafka,apache-zookeeper,Apache Kafka,Apache Zookeeper,我们正在尝试从主题-topic\u 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 ZooKeepe

我们正在尝试从主题-
topic\u 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的
/config
路径下

例如,对于主题
topic\u test

#创建主题
./bin/kafka-topics.sh--引导服务器本地主机:9092--创建\
--topic_test--分区1--复制因子1--配置保留。字节数=12345
#从Zookeeper检索配置
./bin/zookeeper-shell.sh localhost get/config/topics/topic\u test
连接到本地主机
观察者::
WatchedEvent状态:SyncConnected类型:无路径: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
    
    ./bin/kafka-configs.sh --bootstrap-server localhost:9092 --describe --entity-type topics --entity-name topic_test
    
  • kafka configs.sh

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


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

例如,对于主题
topic\u test

#创建主题
./bin/kafka-topics.sh--引导服务器本地主机:9092--创建\
--topic_test--分区1--复制因子1--配置保留。字节数=12345
#从Zookeeper检索配置
./bin/zookeeper-shell.sh localhost get/config/topics/topic\u test
连接到本地主机
观察者::
WatchedEvent状态:SyncConnected类型:无路径: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
    
    ./bin/kafka-configs.sh --bootstrap-server localhost:9092 --describe --entity-type topics --entity-name topic_test
    
  • kafka configs.sh

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


请查看我的有问题的更新-很奇怪,我没有看到保留字节。如果您在创建主题时已在主题上设置了该配置,您只能在Zookeeper中看到
retention.bytes
。如果您使用的是代理默认设置,则不会显示配置。如果您想在所有情况下检索该值,请使用
kafka configs.sh
的管理API。在设置保留字节后,请使用(/bin/kafka-topics.sh--bootstrap server localhost:9092--create\--topic topic_test--partitions 1--replication factor 1--config retention.bytes=12345),然后我们重新启动机器,在重新启动后保留字节不是从zookeeper获得的,是否可以保存它,所以在重新启动后它也会保留?抱歉,这似乎是一个完全不同的问题。请发布另一个包含所有详细信息的问题。这是一篇新帖子-请查看我的更新-非常奇怪,我没有看到保留字节。如果您在创建主题时设置了该主题的配置,您将只在Zookeeper中看到
retention.bytes
。如果您使用的是代理默认设置,则不会显示配置。如果您想在所有情况下检索该值,请使用
kafka configs.sh
的管理API。在设置保留字节后,请使用(/bin/kafka-topics.sh--bootstrap server localhost:9092--create\--topic topic_test--partitions 1--replication factor 1--config retention.bytes=12345),然后我们重新启动机器,在重新启动后保留字节不是从zookeeper获得的,是否可以保存它,所以在重新启动后它也会保留?抱歉,这似乎是一个完全不同的问题。请发布另一个包含所有细节的问题。这是新发布的帖子-