简体   繁体   English

Kafka describe topic 命令列出多个主题描述

[英]Kafka describe topic command lists multiple topics description

Running following command on topic my.topic.test gives description on both my.topic.test and my.topic_test (notice the dot and underscore difference in the names) topics.在主题my.topic.test上运行以下命令my.topic.test给出关于my.topic.testmy.topic_test (注意名称中的点和下划线差异)主题的描述。
Is that desired behavior or a bug (I would lean towards a bug)?这是期望的行为还是错误(我倾向于错误)?

kafka-topics --describe --zookeeper my_zookeeper_ip:2181 --topic my.topic.test
Topic:my.topic.test        PartitionCount:4        ReplicationFactor:1     Configs:
    Topic: my.topic.test       Partition: 0    Leader: 2       Replicas: 2     Isr: 2
    Topic: my.topic.test       Partition: 1    Leader: 3       Replicas: 3     Isr: 3
    Topic: my.topic.test       Partition: 2    Leader: 4       Replicas: 4     Isr: 4
    Topic: my.topic.test       Partition: 3    Leader: 0       Replicas: 0     Isr: 0
Topic:my.topic_test        PartitionCount:5        ReplicationFactor:4     Configs:
    Topic: my.topic_test       Partition: 0    Leader: 4       Replicas: 3,4,5,1       Isr: 4,1,3
    Topic: my.topic_test       Partition: 1    Leader: 4       Replicas: 1,3,4 Isr: 4,1,3
    Topic: my.topic_test       Partition: 2    Leader: 4       Replicas: 4,2,5,3       Isr: 4,3,2
    Topic: my.topic_test       Partition: 3    Leader: 4       Replicas: 5,1,4 Isr: 4,1
    Topic: my.topic_test       Partition: 4    Leader: 1       Replicas: 5,1,3,0       Isr: 1,0,3

When run with --describe , kafka-topics accepts a regex for the --topic argument.当使用--describe运行时, kafka-topics接受--topic参数的正则表达式。 In a regex, .在正则表达式中, . matches any characters so you see the expected behaviour.匹配任何字符,以便您看到预期的行为。

That said, kafka-topics prints a warning when creating a topic with dots or underscores and should have prevented creating 2 topics with such names as metrics would collide:也就是说,kafka-topics 在创建带有点或下划线的主题时会打印警告,并且应该阻止创建 2 个具有诸如指标冲突的名称的主题:

WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('_') could collide. To avoid issues it is best to use either, but not both.

How did you create the topics ?你是如何创建主题的?

first of all ,it's not bug.首先,这不是错误。 according to source-code of kafka-10.2 in topic part Kafka-source ,根据主题部分Kafka-source中 kafka-10.2 的源代码

  val legalChars = "[a-zA-Z0-9\\._\\-]"
  private val maxNameLength = 249
  private val rgx = new Regex(legalChars + "+")

max length of your topic-name can be 249 words,and its treats dot(.) and underscore( _ ) are treated equal.That is your topic name您的主题名称的最大长度可以是 249 个单词,并且它对待点(。)和下划线( _ )是平等的。那就是您的主题名称

my.topic.test, my.topic_test, my_topic.test are same . my.topic.test, my.topic_test, my_topic.test 是一样的。 you should either use ( _ )underscore or dot ( . ) but not both.您应该使用( _ )下划线或点( . ),但不能同时使用。

for best practice i'll recommend you to use hyphen ( - ) like i prefer to use.为了获得最佳实践,我建议您像我喜欢使用的那样使用连字符 ( - )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Kafka 主题到多个 kafka 主题调度程序(同一集群) - Kafka topic to multiple kafka topics dispatcher (same cluster) 如何将一个 Kafka 主题拆分为多个较小的 Kafka 主题? - How to split one Kafka topic into multiple smaller Kafka topics? "Kafka SSL:执行主题命令时创建主题错误:KeeperErrorCode = NoAuth for \/config\/topics\/ssl-topic" - Kafka SSL : Create Topic Error while executing topic command : KeeperErrorCode = NoAuth for /config/topics/ssl-topic Kafka 流 - 多个主题作为同一源还是每个源一个主题? - Kafka streams - Multiple topics as same source or one topic per source? 如果kafka使用者使用多个主题,是否会处理相同的主题密钥? - Does kafka consumer handle same topic keys if it consumes multiple topics? 如何描述主题kafka的配置? - How to describe configuration of topic kafka? 如何更新Kafka主题的描述 - How to update the description of Kafka topic 加入多个 Kafka 主题 - Join on Multiple Kafka Topics 如何使用单个kafka命令列出所有组中的所有主题以及每个主题中的消息总数? - How to list all the topics in all groups with total count of messages in each topic with single kafka command? Kafka ACL:在一个命令中将用户添加到多个主题 - Kafka ACLs: Add user to multiple topics in one command
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM