Apache Kafka 4 cheatsheet

Apache Kafka 4: Start a broker (KRaft)

5 common Apache Kafka 4 tasks.

Generate a cluster ID

Create a random ID for a new cluster.

KAFKA_CLUSTER_ID="$(bin/kafka-storage.sh random-uuid)"

Format the log directories

Prepare storage for a single-node cluster. Do this once per new cluster.

bin/kafka-storage.sh format --standalone -t $KAFKA_CLUSTER_ID -c config/server.properties

Caution: Formatting an existing cluster's storage can destroy its data. Only run it on a new node.

Start the broker

Start Kafka with the default configuration.

bin/kafka-server-start.sh config/server.properties

Check the broker is reachable

List the APIs and versions the broker supports.

bin/kafka-broker-api-versions.sh --bootstrap-server localhost:9092

Check the controller quorum

Show the KRaft quorum status and who the leader is.

bin/kafka-metadata-quorum.sh --bootstrap-server localhost:9092 describe --status

Was this page helpful?