Migrating Kafka from ZooKeeper to KRaft
Learn about migrating an existing Zookeeper-based Kafka cluster to KRaft. Migration is performed in Cloudera Manager using Kafka service actions, and requires minimal user interaction. Additionally, migration is done in a rolling fashion requiring no downtime.
Apache Kafka Raft (KRaft) is a consensus protocol used for metadata management that was developed as a replacement for Apache ZooKeeper. Using KRaft for managing Kafka metadata instead of ZooKeeper offers various benefits including a simplified architecture and a reduced operational footprint.
Migration at glance
Migration is completed in two steps, start and finalize, with the option to revert at any time before finalization. You manage a migration (start, finalize, or revert) using Kafka service actions available in Cloudera Manager.
Most configuration changes needed for migration are handled by Cloudera Manager when you run migration actions. Before starting migration, you are only required to deploy KRaft Controller service roles and configure required policies in Ranger. All other changes are automated by the migration actions.
-
Migrate Kafka to KRaft – Starts migration of Kafka brokers from ZooKeeper to KRaft for the specified Kafka service. Migrates the cluster up to a sate where reverting is still possible.
When this action finishes, brokers will run in KRaft mode and will be disconnected from ZooKeeper. KRaft controllers will still be connected to ZooKeeper and will continue to write metadata to ZooKeeper, but are ready to disconnect (dual-write mode).
-
Finalize KRaft Migration – Finalizes migration by disconnecting KRaft controllers from ZooKeeper. Reverting to ZooKeeper is not possible once this action starts.
-
Revert KRaft Migration – Reverts migration of Kafka brokers from ZooKeeper to KRaft for the specified Kafka service using rolling restarts.
-
Revert KRaft Migration (force restart) – Reverts migration of Kafka brokers from ZooKeeper to KRaft for the specified Kafka service with normal restarts (non-rolling). Expect service downtime when using this action.
You can only start these actions if your cluster meets the required prerequisites. If prerequisites are not met, the actions will be disabled.
Cluster health during migration
During migration and until migration is finalized with the Finalize KRaft Migration action, the health of the Kafka service will be in concerning (yellow) health. This is because the Migrate Kafka to KRaft action stops, starts, and updates the Kafka service roles during the migration process.
The Kafka service will remain in concerning health even after the Migrate Kafka to KRaft action completes successfully. This is because the KRaft Controller roles stay in concerning health until migration is finalized. The KRaft Controllers display one of two health test states that indicate the migration progress:
-
KRaft migration state is: Pre-Migration – Controllers are in migration mode and waiting for brokers to join the migration. This is a transitional state during migration.
-
KRaft migration state is: Migration – Migration is in progress and controllers are running in dual-write mode (writing to both ZooKeeper and KRaft ). The Kafka Controllers will remain in this state until you run the Finalize KRaft Migration action.
Migrating a Kafka cluster to KRaft
You migrate an existing ZooKeeper-based Kafka cluster to KRaft by creating KRaft controllers, configuring required Ranger policies, and using the Migrate Kafka to KRaft Kafka service action in Cloudera Manager.
-
Migrating an existing ZooKeeper-based Kafka cluster KRaft is only available if you are on Cloudera Manager 7.13.2 or later and Cloudera Runtime 7.3.2.
Migration is only possible with this combination of versions. This is because:-
Earlier Cloudera Manager versions do not include the necessary Kafka service actions.
-
Cloudera Runtime 7.3.2 is the only version where migration is possible. Neither previous or future major, minor, and maintenance versions support migration.
-
-
Ensure that all Kafka Broker and ZooKeeper Server roles are running. In addition, ensure that the Kafka and ZooKeeper services do not have stale configurations.
If you have stale configurations, resolve staleness by restarting the service or reverting configuration changes.
-
Ensure that both the Kafka and ZooKeeper services are in a healthy (green) state.
Migration is blocked if the Kafka service is in concerning (yellow) or bad (red) health.
-
The Kafka service must run with inter-broker protocol version 3.9.
Verify the version by checking the value of the Kafka Inter-Broker Protocol Version property in . The value of the property must be
3.9or empty. An empty value means that version is set to the default, which is 3.9 in Cloudera Runtime 7.3.2.
The Kafka service will be in a concerning (yellow) health state. This is because the KRaft Controller roles will stay in a concerning health with the KRaft migration state is: Migration health test state until the migration is finalized. This is normal and expected behavior. This health test state indicates that migration is not yet finalized.
Finalizing a KRaft migration
You finalize ZooKeeper to KRaft migration with the Finalize KRaft Migration Kafka service action in Cloudera Manager.
- Ensure that the Migrate Kafka to KRaft action has
successfully finished.
If your KRaft Controller roles are in a concerning health state with the KRaft migration state is: Migration health test state, you can safely proceed with finalization. This health test state indicates that the service is ready for finalization.
- Ensure that all applications or services that connect to Kafka operate normally and can produce or consume messages.
- In Cloudera Manager select the Kafka service.
- Click .
- Wait until the action finishes.
Reverting a Kafka cluster to ZooKeeper
You revert migration with the Revert KRaft Migration or Revert KRaft Migration (force restart) Kafka service actions in Cloudera Manager.
Reverting to ZooKeeper is only possible if the migration to KRaft is not finalized. A migration is not finalized if the KRaft Controller roles are in a concerning health state with the KRaft migration state is: Migration health test state.
