简体   繁体   English

Apache Kafka KRaft - Kafka 存储工具

[英]Apache Kafka KRaft - Kafka Storage Tool

in the documentation it is mentioned that:文档中提到:

As described above in the QuickStart section, you must use the kafka-storage.sh tool to generate a cluster ID for your new cluster, and then run the format command on each node before starting the node.如上面快速入门部分所述,您必须使用 kafka-storage.sh 工具为您的新集群生成一个集群 ID,然后在启动该节点之前在每个节点上运行 format 命令。

Generate a cluster ID生成集群 ID

./bin/kafka-storage.sh random-uuid
xtzWWN4bTjitpL3kfd9s5g

Format Storage Directories格式化存储目录

./bin/kafka-storage.sh format -t <uuid> -c ./config/kraft/server.properties
Formatting /tmp/kraft-combined-logs

would be it a problem to generate the <uuid> with a different program and not with the kafka-storage.sh one?使用不同的程序而不是kafka-storage.sh生成<uuid>会不会有问题?

It needs to be a type-4 UUID that doesn't match Kafka's internal UUIDs它需要是一个与 Kafka 的内部 UUID 不匹配的类型 4 UUID

From Kafka source-code来自 Kafka 源代码

    /**
     * Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
     */
    public static Uuid randomUuid() {
        java.util.UUID uuid = java.util.UUID.randomUUID();
        while (uuid.equals(METADATA_TOPIC_ID_INTERNAL) || uuid.equals(ZERO_ID_INTERNAL)) {
            uuid = java.util.UUID.randomUUID();
        }
        return new Uuid(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits());
    }

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM