Skip to main content
Welcome back. In this lesson we walk through setting up Apache Kafka in KRaft (Kafka Raft Metadata) mode on a CentOS (KodeKloud Lab) machine. This step-by-step guide covers downloading Kafka, inspecting KRaft configuration, generating a cluster ID, formatting local metadata storage, starting Kafka in KRaft mode, and verifying the startup logs. Why KRaft?
  • KRaft removes the dependency on ZooKeeper by storing cluster metadata in a Raft quorum.
  • Recommended for new Kafka deployments, since Kafka is migrating metadata management to KRaft.
Overview
  • Download a Kafka release
  • Extract and inspect the Kafka directory
  • Inspect config/kraft and key KRaft config files
  • Generate a cluster ID (UUID)
  • Format local storage for KRaft metadata
  • Start Kafka in KRaft mode and verify logs
Prerequisites
  • CentOS (or similar Linux) with wget and tar installed
  • Java installed and JAVA_HOME configured
  • Sufficient disk space for Kafka logs (default uses /tmp unless changed in config)
Download and extract Apache Kafka
  1. Download Kafka 3.0.0 (Scala 2.13) tarball:
Example wget output (truncated):
  1. Extract the archive:
Inspect the Kafka directory Change into the extracted directory and list the top-level contents:
You should see familiar top-level folders such as config, bin, libs, and site-docs. Inspect the config directory and KRaft-specific configs Change into config and examine KRaft-related files:
There is a dedicated kraft/ subdirectory containing KRaft config files:
Common contents of config/kraft: For simple single-node testing you often can use the defaults. For production clusters tune the controller.properties and broker.properties as needed. Generate a cluster ID (random UUID) KRaft stores metadata locally and requires an initial formatting step. First generate a cluster ID (a random UUID) using Kafka’s helper script:
Sample output (your UUID will be different):
Format the local storage with the generated UUID Use the kafka-storage.sh format command to initialize the local metadata storage. Replace the UUID below with the one returned by random-uuid. Also point to the server.properties inside config/kraft.
What this does:
  • Initializes the KRaft metadata directory (default path is typically /tmp/kraft-combined-logs unless changed in server.properties)
  • Writes the initial metadata snapshot and prepares the node to become part of a Raft quorum
Start Kafka in KRaft mode After formatting the storage, start the Kafka broker using the same server.properties:
When started, the broker runs with the KRaft controller logic enabled (no separate ZooKeeper or controller process needed for KRaft). Verify KRaft startup in the logs As Kafka starts in KRaft mode, the logs will include Raft and controller lifecycle events. Look for messages indicating Raft transitions, controller startup, and the broker listening on configured ports. Example log excerpts (truncated):
How to tell if KRaft is being used
  • Look for Raft/Controller-related logs such as RaftManager, KafkaRaftClient, ControllerServer — these indicate KRaft mode.
  • If ZooKeeper were in use, you would instead see ZooKeeper connection logs and zookeeper.* properties being used.
Configuration notes and key properties Below are examples of server properties and status values you may see when running in KRaft mode. These illustrate that ZooKeeper is not used and show transaction/replication defaults.
Common KRaft-related settings to review Recommendation
For new Kafka deployments, prefer KRaft mode (ZooKeeper-less) because Kafka is moving towards KRaft for metadata management. Use the config/kraft files (server.properties, controller.properties, broker.properties) to tune controller and broker behavior as your cluster grows.
Troubleshooting tips
  • If the broker fails to start, check that the node.id, process.roles, and controller.quorum.voters values are correct for your topology.
  • Ensure the metadata directory specified in server.properties is writable by the Kafka process.
  • If you see ZooKeeper-related settings populated, confirm you are using the config/kraft/server.properties file when formatting and starting Kafka.
Links and References That is all for this lesson/article. See you in the next lesson.

Watch Video

Practice Lab