Complete installation & configuration guide for Apache Kafka 3.6.1 with Zookeeper on Ubuntu/Debian — including broker setup, topic management, and log verification.
Understand the full log flow architecture before you begin. Each component plays a distinct role in the pipeline.
Kafka requires Java 8+. OpenJDK 17 is recommended for production.
sudo apt update
sudo apt install openjdk-17-jdk -y # Ubuntu/Debian
java -version
cd /opt
sudo wget https://archive.apache.org/dist/kafka/3.6.1/kafka_2.13-3.6.1.tgz
sudo tar -xvf kafka_2.13-3.6.1.tgz
sudo mv kafka_2.13-3.6.1 kafka
sudo nano /opt/kafka/config/zookeeper.properties
# Directory where the snapshot is stored
dataDir=/tmp/zookeeper
# Port at which clients connect
clientPort=2181
# Disable per-ip connection limit (non-production)
maxClientCnxns=0
# Disable admin server to avoid port conflicts
admin.enableServer=false
# admin.serverPort=8080
cd /opt/kafka
bin/zookeeper-server-start.sh config/zookeeper.properties
The main configuration file is server.properties — key settings below.
sudo nano /opt/kafka/config/server.properties
# Broker ID
broker.id=0
# Log storage
log.dirs=/var/lib/kafka-logs
# Network listeners
listeners=PLAINTEXT://0.0.0.0:9092
# Advertised address for clients (applications, Logstash)
advertised.listeners=PLAINTEXT://<BROKER_IP>:9092
# Zookeeper connection
zookeeper.connect=localhost:2181
# Topic retention
log.retention.hours=168
log.segment.bytes=1073741824
# Optional: enable auto topic creation
auto.create.topics.enable=true
cd /opt/kafka
bin/kafka-server-start.sh config/server.properties
Verify broker config at runtime via Kafka scripts:
/opt/kafka/bin/kafka-configs.sh \
--bootstrap-server 192.168.20.208:9092 \
--entity-type brokers \
--describe
Shows broker-specific configs like num.network.threads, log.dirs, etc.
bin/kafka-topics.sh --create --topic test --bootstrap-server localhost:9092
/opt/kafka/bin/kafka-topics.sh --create \
--topic application_logs \
--bootstrap-server localhost:9092 \
--partitions 3 \
--replication-factor 1
/opt/kafka/bin/kafka-topics.sh \
--bootstrap-server 192.168.20.208:9092 \
--describe
/opt/kafka/bin/kafka-console-consumer.sh \
--bootstrap-server 192.168.20.208:9092 \
--topic application_logs \
--from-beginning
Continue with these guides to complete the full ELK stack setup: