Step-by-step guide on installing and configuring Apache Kafka with ZooKeeper on a CentOS machine.
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.
drwxr-xr-x 7 bob bob 4096 Apr 16 18:06 kafka_2.13-3.0.0-rw-r--r-- 1 bob bob 8639620 Apr 16 18:06 kafka_2.13-3.0.0.tgz
Enter the Kafka directory and inspect its contents:
Copy
Ask AI
cd kafka_2.13-3.0.0ls -l
Expected output:
Copy
Ask AI
total 64-rw-r--r-- 1 bob bob 14521 Sep 8 2021 LICENSE-rw-r--r-- 1 bob bob 28104 Sep 8 2021 NOTICEdrwxr-xr-x 3 bob bob 4096 Sep 8 2021 configdrwxr-xr-x 2 bob bob 4096 Sep 8 2021 bindrwxr-xr-x 2 bob bob 4096 Apr 16 18:06 libsdrwxr-xr-x 2 bob bob 4096 Sep 8 2021 site-docs
cd ..bin/zookeeper-server-start.sh config/zookeeper.properties
Look for log messages confirming startup:
Copy
Ask AI
[2025-04-16 18:09:25,277] INFO binding to port 0.0.0.0:2181 (org.apache.zookeeper.server.NettyServerCnxnFactory)[2025-04-16 18:09:25,360] INFO zookeeper.snapshotSizeFactor = 0.33 (org.apache.zookeeper.server.persistence.SnapTxn)[2025-04-16 18:09:25,484] INFO ZooKeeper audit is disabled. (org.apache.zookeeper.server.XidAuditProvider)
Scroll until you see the ASCII-art startup banner:
Watch the console to confirm the broker connects to ZooKeeper:
Copy
Ask AI
[2025-04-16 18:10:53,771] INFO starting (kafka.server.KafkaServer)[2025-04-16 18:10:53,783] INFO Connecting to zookeeper on localhost:2181. (kafka.zookeeper.ZooKeeperClient)[2025-04-16 18:10:53,803] INFO Client environment: zookeeper.version=3.6.3-401e4ad2087061cb6bf980dec2d69f2e3c8660a, built on 04/08/2021 16:35 GMT (org.apache.zookeeper.ZooKeeper)
Kafka will fail to start if ZooKeeper is not running. Always verify ZooKeeper logs before launching the broker.
You have successfully set up a standalone ZooKeeper server and launched an Apache Kafka broker connected to it. In future lessons, we will explore topic creation, message publishing, and consumer groups.