Welcome to this step-by-step guide on installing and configuring Apache Kafka 3.0.0 with ZooKeeper. By the end of this tutorial, you’ll understand how Kafka depends on ZooKeeper and how to launch both services on a CentOS machine.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- Java 8 or later installed (
java -version) wgetandtarutilities available- Internet access to download Kafka binaries
1. Download and Extract Kafka
-
Fetch the Kafka 3.0.0 distribution:
-
Unpack the archive:
-
Verify extraction:
Sample output:
-
Enter the Kafka directory and inspect its contents:
Expected output:
2. Explore ZooKeeper Scripts
Thebin directory includes several scripts related to ZooKeeper. List them with:
| Script Name | Purpose |
|---|---|
| zookeeper-shell.sh | Interactive ZooKeeper shell |
| zookeeper-server-start.sh | Start a standalone ZooKeeper server |
| zookeeper-server-stop.sh | Stop the ZooKeeper server |
| zookeeper-security-migration.sh | Migrate security settings in ZooKeeper |
3. Review ZooKeeper Configuration
Navigate to the configuration folder and inspect the default properties:zookeeper.properties file defines:
dataDir: Directory to store ZooKeeper snapshots and logsclientPort: Port on which ZooKeeper listens (default2181)tickTime: Basic time unit in milliseconds
You can customize
zookeeper.properties to enable multi-node clusters by adding server.X entries.4. Start ZooKeeper
From the Kafka root directory, launch ZooKeeper:5. Start the Kafka Broker
- Open a new terminal window.
- Change into the Kafka installation directory:
- Start the broker with the default server configuration:
server.properties contains:
Kafka will fail to start if ZooKeeper is not running. Always verify ZooKeeper logs before launching the broker.