Bird
Raised Fist0
Kafkadevops~20 mins

Kafka installation and setup - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Kafka Setup Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What is the output of this Kafka console producer command?
You run the following command to send a message to a Kafka topic named test-topic. What will be the output shown in the terminal after sending the message?
Kafka
echo "Hello Kafka" | kafka-console-producer.sh --broker-list localhost:9092 --topic test-topic
AError: Topic 'test-topic' does not exist
BProducer started, waiting for input
CMessage sent successfully with no output
DHello Kafka
Attempts:
2 left
💡 Hint
The console producer command sends the message silently unless there is an error.
🧠 Conceptual
intermediate
1:30remaining
Which service must be running before starting Kafka broker?
Before starting the Kafka broker, which service must be running to ensure Kafka works properly?
AZookeeper
BKafka Connect
CKafka Streams
DKafka Producer
Attempts:
2 left
💡 Hint
Kafka uses this service to manage cluster metadata and leader election.
🔧 Debug
advanced
2:30remaining
Why does Kafka broker fail to start with this error?
You try to start Kafka broker but get this error: ERROR Fatal error during KafkaServer startup. The logs show Port 9092 already in use. What is the most likely cause?
Kafka
bin/kafka-server-start.sh config/server.properties
AZookeeper is not running
BAnother Kafka broker or process is already using port 9092
CThe server.properties file is missing
DKafka version is incompatible with Java version
Attempts:
2 left
💡 Hint
Check if any other process is using the default Kafka port.
📝 Syntax
advanced
2:00remaining
Which command correctly creates a Kafka topic named 'orders' with 3 partitions?
Select the correct command to create a Kafka topic named orders with 3 partitions and a replication factor of 1.
Akafka-topics.sh --create --topic orders --partitions 3 --replication-factor 1 --bootstrap-server localhost:9092
Bkafka-topics.sh --create --topic orders --partition 3 --replication 1 --zookeeper localhost:2181
Ckafka-topics.sh --create --topic orders --partitions=3 --replication-factor=1 --bootstrap-server localhost:9092
Dkafka-topics.sh --create orders --partitions 3 --replication-factor 1 --bootstrap-server localhost:9092
Attempts:
2 left
💡 Hint
Check the exact option names and syntax for partitions and replication factor.
🚀 Application
expert
3:00remaining
How to configure Kafka broker to listen on all network interfaces?
You want your Kafka broker to accept connections from any IP address on your machine. Which configuration setting in server.properties achieves this?
Aadvertised.listeners=PLAINTEXT://0.0.0.0:9092
Badvertised.listeners=PLAINTEXT://localhost:9092
Clisteners=PLAINTEXT://127.0.0.1:9092
Dlisteners=PLAINTEXT://0.0.0.0:9092
Attempts:
2 left
💡 Hint
The listeners setting controls where Kafka binds to accept connections.

Practice

(1/5)
1. What is the first step to start Kafka on your local machine?
easy
A. Start Zookeeper service
B. Create Kafka topics
C. Run Kafka producer
D. Install Java

Solution

  1. Step 1: Understand Kafka dependencies

    Kafka requires Zookeeper to coordinate its services.
  2. Step 2: Start Zookeeper before Kafka

    You must start Zookeeper first to allow Kafka to connect and run properly.
  3. Final Answer:

    Start Zookeeper service -> Option A
  4. Quick Check:

    Kafka needs Zookeeper first = Start Zookeeper service [OK]
Hint: Always start Zookeeper before Kafka server [OK]
Common Mistakes:
  • Starting Kafka before Zookeeper
  • Skipping Zookeeper start
  • Trying to create topics before server runs
2. Which command correctly starts the Kafka server after Zookeeper is running?
easy
A. bin/kafka-topics.sh --create --topic test
B. bin/zookeeper-server-start.sh config/zookeeper.properties
C. bin/kafka-server-start.sh config/server.properties
D. bin/kafka-console-producer.sh --topic test

Solution

  1. Step 1: Identify Kafka server start command

    The Kafka server is started using kafka-server-start.sh with server properties.
  2. Step 2: Differentiate from other commands

    Zookeeper start uses zookeeper-server-start.sh; topic creation and producer commands are different tools.
  3. Final Answer:

    bin/kafka-server-start.sh config/server.properties -> Option C
  4. Quick Check:

    Kafka server start = bin/kafka-server-start.sh config/server.properties [OK]
Hint: Kafka server uses kafka-server-start.sh script [OK]
Common Mistakes:
  • Using zookeeper start command for Kafka
  • Confusing topic creation with server start
  • Running producer before server
3. What will be the output when you run this command after starting Kafka server?
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
medium
A. Lists all existing Kafka topics
B. Starts the Kafka server
C. Creates a new topic named 'localhost'
D. Shows Zookeeper status

Solution

  1. Step 1: Understand the command purpose

    The command lists topics using the Kafka bootstrap server address.
  2. Step 2: Identify output type

    It outputs all existing topics in Kafka, not starting server or creating topics.
  3. Final Answer:

    Lists all existing Kafka topics -> Option A
  4. Quick Check:

    --list shows topics = Lists all existing Kafka topics [OK]
Hint: Use --list with --bootstrap-server to see topics [OK]
Common Mistakes:
  • Thinking it starts Kafka server
  • Assuming it creates topics
  • Confusing with Zookeeper commands
4. You tried to start Kafka server but got an error saying 'Could not connect to Zookeeper'. What is the likely cause?
medium
A. Kafka server is already running
B. Zookeeper service is not running
C. Topic name is missing
D. Java is not installed

Solution

  1. Step 1: Analyze error message

    'Could not connect to Zookeeper' means Kafka cannot reach Zookeeper service.
  2. Step 2: Identify cause

    This usually happens if Zookeeper is not started or crashed.
  3. Final Answer:

    Zookeeper service is not running -> Option B
  4. Quick Check:

    Connection error = Zookeeper not running [OK]
Hint: Check Zookeeper is running before Kafka start [OK]
Common Mistakes:
  • Ignoring Zookeeper status
  • Assuming Kafka server conflict
  • Blaming missing topic name
5. You want to test Kafka by sending messages to a topic named 'test'. Which sequence of commands is correct after starting Zookeeper and Kafka server?
hard
A. Start kafka-console-consumer.sh, then create topic with kafka-topics.sh
B. Only start Zookeeper and produce messages directly
C. Run kafka-server-start.sh twice, then produce messages
D. Create topic with kafka-topics.sh, then produce messages with kafka-console-producer.sh

Solution

  1. Step 1: Create the topic first

    You must create the topic 'test' before sending messages to it.
  2. Step 2: Use producer to send messages

    After topic creation, use kafka-console-producer.sh to send messages to 'test'.
  3. Final Answer:

    Create topic with kafka-topics.sh, then produce messages with kafka-console-producer.sh -> Option D
  4. Quick Check:

    Create topic then produce = Create topic with kafka-topics.sh, then produce messages with kafka-console-producer.sh [OK]
Hint: Create topic before producing messages [OK]
Common Mistakes:
  • Producing messages before topic creation
  • Starting Kafka server twice unnecessarily
  • Skipping Kafka server start
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard