Debugging Kafka Installation: A Step-by-Step Guide
In this blog post, we’ll walk through a real-world example of debugging a Kafka installation. We’ll cover the common issues encountered and how to resolve them.
The Problem
The user was trying to create a Kafka topic using the kafka-topics.sh script but encountered an error because the --zookeeper option was not recognized. This was likely because the user was using a version of Kafka (2.13-3.7.0) that no longer uses Zookeeper.
The Solution
From Kafka version 2.8.0 onwards, Kafka has started the process of removing the dependency on Zookeeper and has introduced a new mode called KRaft (Kafka Raft metadata mode) where Kafka manages its own metadata information. So, instead of using --zookeeper, the user should use the --bootstrap-server option to specify the address of the Kafka broker.
Further Issues
The user then encountered a connection issue with the Kafka broker. The error message indicated that the Kafka client was unable to establish a connection to the Kafka broker at localhost:9092. This could be due to several reasons:
Kafka Server is not running
Incorrect Host/Port
Firewall Rules
Network Issues
The user checked the Kafka server and found it was not running. The user then started the Kafka server but encountered another issue - the Kafka server was still looking for Zookeeper.
Enabling KRaft Mode
To resolve this, the user needed to enable KRaft mode in Kafka. This involved initializing the Kafka storage with a cluster ID and updating the Kafka server properties file. However, the user encountered issues with the kraft-server-start.sh script not being present in their Kafka installation.
Checking the Kafka Version
The user was using the latest version of Kafka, which supports KRaft mode. However, KRaft mode is not the default and needs to be explicitly enabled. The user tried to enable KRaft mode but encountered issues with the server.properties file not being found.
Final Resolution
Finally, the user was able to start the Kafka server successfully. The logs confirmed that the Kafka server was awaiting socket connections and had successfully connected to the controller node.
Conclusion
Debugging a Kafka installation can involve a variety of steps, from checking the Kafka and Zookeeper services to configuring Kafka to run in KRaft mode. It’s important to understand the changes in recent Kafka versions and how they affect the installation and configuration process. With careful troubleshooting and the right configuration settings, you can get your Kafka server up and running.