Skip to main content
Welcome — this guide walks through setting up Apache Kafka with ZooKeeper on a CentOS (or similar) Linux host. It explains how Kafka depends on ZooKeeper, how to start both services, and how to verify they are communicating. Prerequisite
  • A CentOS machine (or similar Linux host) with network access to download Kafka binaries.
Step 1 — Download and extract Kafka Download the Kafka 3.0.0 binary and extract it:
List and change into the extracted directory:
Notes:
  • All start/stop scripts are in the bin directory.
  • Default configuration files live in config.
Step 2 — Inspect ZooKeeper-related scripts Change into bin and list ZooKeeper scripts:
Quick reference table for the files you’ll use: Step 3 — Inspect the default ZooKeeper config The default ZooKeeper configuration file is config/zookeeper.properties. List the config directory:
What to check in zookeeper.properties:
  • Client port (default: 2181)
  • Data directory (dataDir)
  • Clustering settings (if running an ensemble)
Step 4 — Start ZooKeeper You can start ZooKeeper either from the Kafka root or from the bin directory. Example — start from Kafka root:
Example — start from bin directory:
Tip: If you see a path-related error, confirm the relative path to zookeeper.properties matches your current working directory. ZooKeeper startup logs (stdout) include lines such as:
By default ZooKeeper listens on port 2181 (the client port). Kafka connects to ZooKeeper on that port unless you change zookeeper.connect in Kafka’s server.properties.
Step 5 — Start the Kafka broker (in a new terminal) Open a second terminal, change into the Kafka folder, and start the broker:
During startup Kafka reads server.properties. By default it contains:
Watch the broker logs for confirmation it started and connected to ZooKeeper:
Troubleshooting
  • If Kafka cannot connect to ZooKeeper, it will fail during broker initialization. Confirm:
    • ZooKeeper is running and reachable on the address in zookeeper.connect.
    • Network/iptables allow traffic to port 2181.
    • The server.properties and zookeeper.properties file paths are correct when launching the scripts.
Conclusion This demo covered:
  • Downloading and extracting Kafka binaries
  • Locating ZooKeeper startup scripts and configuration files
  • Starting ZooKeeper and verifying it binds to port 2181
  • Starting the Kafka broker and confirming it connects to ZooKeeper
Further reading and references

Watch Video

Practice Lab