Skip to content

kafka-metadata-shell Tool utility is a Kafka metadata tool to interactively examine the metadata stored in a KRaft cluster. can read the metadata from a metadata snapshot on disk.

KafkaRaftManager Not Supported Yet

There is no support to specify a KafkaRaftManager on command line yet.

Based on and metadata.log.max.record.bytes.between.snapshots, KRaft controllers write metadata snapshots to cluster metadata topic's log directory (using SnapshotGenerator and SnapshotEmitter).

INFO [SnapshotGenerator id=1] Creating new KRaft snapshot file snapshot 00000000000000061020-0000000002 because we have waited at least 60 minute(s).
INFO [SnapshotEmitter id=1] Successfully wrote snapshot 00000000000000061020-0000000002

Use --snapshot option to load the snapshot file.

$ ./bin/ \
  --snapshot /tmp/kraft-controller-logs/__cluster_metadata-0/00000000000000061020-0000000002.checkpoint
[ Kafka Metadata Shell ]
>> help
Welcome to the Apache Kafka metadata shell.

usage:  {cat,cd,exit,find,help,history,ls,man,pwd,tree} ...

positional arguments:
    cat                  Show the contents of metadata files.
    cd                   Set the current working directory.
    exit                 Exit the metadata shell.
    find                 Search for nodes in the directory hierarchy.
    help                 Display this help message.
    history              Print command history.
    ls                   List metadata nodes.
    man                  Show the help text for a specific command.
    pwd                  Print the current working directory.
    tree                 Show the contents of metadata nodes in a tree structure.
>> ls
image  local

The metadata tool works by replaying the log and storing the state into in-memory nodes. These nodes are presented in a fashion similar to filesystem directories.

>> man tree
tree: Show the contents of metadata nodes in a tree structure.

usage: tree targets [targets ...]

positional arguments:
  targets                The metadata nodes to display.
>> tree local
  3.6.0 uses MetadataShell as an entry point.



--snapshot (-s) is a metadata snapshot file to read.