Updating a Kafka environment to use KRaft (Kafka Raft) mode instead of ZooKeeper involves several steps. KRaft mode is a new feature in Apache Kafka that allows Kafka brokers to manage metadata directly, eliminating the need for ZooKeeper. This transition involves setting up a new Kafka cluster in KRaft mode, migrating data, and updating configurations.
Download and Install Kafka:
wget <https://downloads.apache.org/kafka/3.2.0/kafka_2.13-3.2.0.tgz>
tar -xzf kafka_2.13-3.2.0.tgz
cd kafka_2.13-3.2.0
Create a New Configuration File:
server.properties
.# Basic Kafka settings
process.roles=broker,controller
node.id=1
controller.quorum.voters=1@localhost:9093
listeners=PLAINTEXT://localhost:9092,CONTROLLER://localhost:9093
inter.broker.listener.name=PLAINTEXT
log.dirs=/tmp/kraft-combined-logs
Additional Configuration:
log.retention.hours=168
num.partitions=1
default.replication.factor=1
min.insync.replicas=1
Format the Kafka Storage:
bin/kafka-storage.sh format -t <uuid> -c config/server.properties
<uuid>
with a unique identifier. You can generate one using uuidgen
or similar.uuidgen
Start the Kafka Broker:
bin/kafka-server-start.sh config/server.properties
kafka-reassign-partitions.sh
and kafka-mirror-maker.sh
to migrate topics and data from the old ZooKeeper-based cluster to the new KRaft-based cluster.