Prerequisites
- CentOS 7 or later
- Java 11+ installed (
java -version) - Minimum 4 GB RAM and 2 CPU cores
Download and Extract Apache Kafka
-
Download Kafka 3.0.0 (Scala 2.13):
-
Extract the archive:
-
Enter the Kafka directory:
Explore the Directory Structure
List the top-level folders:config directory and view the KRaft config files:
| File | Purpose | Default Path |
|---|---|---|
| controller.properties | Configuration for the Raft controller (metadata) | config/kraft/controller.properties |
| server.properties | Broker settings + Raft metadata directories | config/kraft/server.properties |
You can customize log directories, ports, and listeners in these files before formatting storage.
Format Local Storage for KRaft
Before starting Kafka, initialize local storage and bind it to a cluster ID.-
Generate a UUID for your cluster:
-
Format the storage with the generated UUID:
This embeds the cluster ID into the log directories (default:
/tmp/kraft-logs).
Reformatting storage erases existing logs. Only run this command once on a fresh directory.
Start Kafka in KRaft Mode
Launch the combined broker and controller process:KafkaRaftServer and no zookeeper.connect references, your cluster is running in KRaft mode.
Verifying KRaft vs. ZooKeeper
- KRaft mode logs mention RaftManager and KafkaRaftServer.
- There are no ZooKeeper processes or settings.
- The controller and broker run within a single JVM.
Next Steps
- Create topics:
- Produce and consume messages:
- Scale to multi-node KRaft clusters by repeating storage formatting with unique IDs and updating
controller.quorum.voters.