How it works
The explanation, with examples you can run.
Roles
# a dedicated controllerprocess.roles=controllernode.id=1listeners=CONTROLLER://controller1.example.com:9093controller.listener.names=CONTROLLERcontroller.quorum.bootstrap.servers=controller1.example.com:9093,controller2.example.com:9093,controller3.example.com:9093process.roles can be broker, controller, or broker,controller (combined). Combined servers are convenient for development and small clusters; the documentation's caution is that a controller sharing a machine with a broker is less isolated from broker load. Every node is formatted once with a cluster id (kafka-storage.sh random-uuid, then kafka-storage.sh format); Kafka no longer formats storage automatically.
The quorum
On the three-node test cluster (combined mode):
bin/kafka-metadata-quorum.sh --bootstrap-server kafka1:9092 describe --statusClusterId: anD7Csf_SH-oHi5O2uMR7wLeaderId: 1LeaderEpoch: 1HighWatermark: 42MaxFollowerLag: 0MaxFollowerLagTimeMs: 0CurrentVoters: [{"id": 1, ...}, {"id": 2, ...}, {"id": 3, ...}]One controller is the active leader of the metadata log; the others are hot standbys with the log already applied, so failover is quick. A majority of voters must be alive: 3 controllers tolerate one failure, 5 tolerate two. Lose the majority and existing partition leaders keep serving, but nothing in the metadata can change, which includes electing new partition leaders when a broker fails.
The features command shows what the cluster has switched on. On 4.1.0:
Feature: eligible.leader.replicas.version ... FinalizedVersionLevel: 1Feature: group.version ... FinalizedVersionLevel: 1Feature: kraft.version ... FinalizedVersionLevel: 0Feature: metadata.version ... FinalizedVersionLevel: 4.1-IV1Feature: share.version ... FinalizedVersionLevel: 0Feature: transaction.version ... FinalizedVersionLevel: 2group.version 1 enables the new consumer protocol on the broker, transaction.version 2 the strengthened transaction protocol, and kraft.version 0 means a static controller set; Kafka 4.1 added an upgrade to dynamic controller membership, so controllers can be added and removed.
Upgrading from ZooKeeper
A ZooKeeper-mode cluster cannot be upgraded straight to 4.x. It must first be migrated to KRaft on a 3.x release that supports migration (3.9, the last 3.x release, is the usual choice), with the controllers copying the metadata from ZooKeeper and the brokers then restarted in KRaft mode. Some configurations and metrics that only existed for ZooKeeper are gone. Java requirements also changed in 4.0: brokers need Java 17, clients Java 11.
Check yourself
3 questions. Get them all right to finish this topic.
0 of 3 right so far. Get all three to finish this topic.