0
0
Kafkadevops~10 mins

Kafka installation and setup - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Kafka installation and setup
Download Kafka
Extract Files
Start Zookeeper
Start Kafka Server
Create Topics
Produce and Consume Messages
Shutdown Kafka and Zookeeper
This flow shows the main steps to install and set up Kafka: download, extract, start Zookeeper, start Kafka, create topics, use Kafka, then shutdown.
Execution Sample
Kafka
wget https://downloads.apache.org/kafka/3.5.1/kafka_2.13-3.5.1.tgz

tar -xzf kafka_2.13-3.5.1.tgz

cd kafka_2.13-3.5.1

bin/zookeeper-server-start.sh config/zookeeper.properties

bin/kafka-server-start.sh config/server.properties
This code downloads Kafka, extracts it, starts Zookeeper, then starts the Kafka server.
Process Table
StepActionCommand RunResultNext Step
1Download Kafka archivewget https://downloads.apache.org/kafka/3.5.1/kafka_2.13-3.5.1.tgzKafka archive downloadedExtract Files
2Extract Kafka filestar -xzf kafka_2.13-3.5.1.tgzKafka files extracted to folder kafka_2.13-3.5.1Change Directory
3Change directory to Kafka foldercd kafka_2.13-3.5.1Current directory is kafka_2.13-3.5.1Start Zookeeper
4Start Zookeeper servicebin/zookeeper-server-start.sh config/zookeeper.propertiesZookeeper started and runningStart Kafka Server
5Start Kafka serverbin/kafka-server-start.sh config/server.propertiesKafka server started and runningCreate Topics
6Create a Kafka topicbin/kafka-topics.sh --create --topic test --bootstrap-server localhost:9092Topic 'test' createdProduce Messages
7Produce messages to topicbin/kafka-console-producer.sh --topic test --bootstrap-server localhost:9092Ready to accept messagesConsume Messages
8Consume messages from topicbin/kafka-console-consumer.sh --topic test --from-beginning --bootstrap-server localhost:9092Messages received and displayedShutdown
9Shutdown Kafka serverCtrl+C or kill processKafka server stoppedShutdown Zookeeper
10Shutdown ZookeeperCtrl+C or kill processZookeeper stoppedEnd
💡 All services stopped, Kafka installation and setup complete
Status Tracker
Variable/ServiceStartAfter Step 4After Step 5After Step 9After Step 10
ZookeeperNot runningRunningRunningRunningStopped
Kafka ServerNot runningNot runningRunningStoppedStopped
Kafka Topic 'test'Not createdNot createdCreatedCreatedCreated
Key Moments - 3 Insights
Why do we need to start Zookeeper before Kafka server?
Kafka depends on Zookeeper to manage cluster metadata. As shown in execution_table step 4, Zookeeper must be running before starting Kafka server in step 5.
What happens if we try to create a topic before starting Kafka server?
The topic creation will fail because Kafka server is not running to accept commands. Execution_table shows topic creation only after Kafka server starts at step 6.
How do we stop Kafka and Zookeeper services safely?
Use Ctrl+C or kill the processes as in steps 9 and 10. This cleanly stops the services to avoid data loss.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step does Kafka server start running?
AStep 5
BStep 4
CStep 6
DStep 7
💡 Hint
Check the 'Result' column for when Kafka server status changes to running.
According to variable_tracker, what is the status of Zookeeper after step 9?
AStopped
BNot running
CRunning
DStarting
💡 Hint
Look at the Zookeeper row and the column 'After Step 9' in variable_tracker.
If you skip step 4 and start Kafka server directly, what will likely happen?
AKafka server starts normally
BKafka server fails to start
CTopic creation succeeds
DZookeeper starts automatically
💡 Hint
Refer to key_moments about the dependency of Kafka on Zookeeper before starting.
Concept Snapshot
Kafka Installation and Setup Quick Steps:
1. Download and extract Kafka archive.
2. Start Zookeeper service first.
3. Start Kafka server next.
4. Create topics and produce/consume messages.
5. Shutdown Kafka and Zookeeper cleanly.
Remember: Zookeeper must run before Kafka server.
Full Transcript
This visual execution shows the step-by-step process to install and set up Kafka. First, you download the Kafka archive and extract it. Then you start the Zookeeper service, which Kafka needs to manage its cluster. After Zookeeper is running, you start the Kafka server. Next, you create topics to organize messages. You can then produce messages to these topics and consume them to verify Kafka is working. Finally, you stop the Kafka server and then Zookeeper to finish the setup safely. The tables track each step's commands, results, and the state of services. Key moments clarify why Zookeeper must start first and how to stop services properly. The quiz tests understanding of these steps and dependencies.