Apache Kafka Kafka Admin & Operations 1 — Questions and Answers
Question 1: Which command-line tool is used to create, delete, describe, and alter Kafka topics?
- kafka-console-producer.sh
- kafka-topics.sh (Correct answer)
- kafka-admin.sh
- kafka-cluster.sh
Correct answer: kafka-topics.sh
kafka-topics.sh is the standard CLI tool for managing Kafka topics including create, delete, alter, and describe operations.
Question 2: What is the default value for the `log.retention.hours` configuration in Apache Kafka?
- 24 hours
- 48 hours
- 168 hours (7 days) (Correct answer)
- 720 hours (30 days)
Correct answer: 168 hours (7 days)
The default log.retention.hours is 168 hours (7 days), after which messages are eligible for deletion by the log cleaner.
Question 3: What happens when `unclean.leader.election.enable` is set to true on a Kafka broker?
- Leaders are elected only from in-sync replicas
- Out-of-sync replicas can become leaders, potentially causing data loss (Correct answer)
- Leader election is disabled entirely
- Only the controller broker can initiate leader elections
Correct answer: Out-of-sync replicas can become leaders, potentially causing data loss
When unclean.leader.election.enable=true, replicas not in the ISR can be elected leader, improving availability at the cost of potential data loss.
Question 4: Which CLI tool is used to list, describe, and reset consumer group offsets in Kafka?
- kafka-consumer-groups.sh (Correct answer)
- kafka-offsets.sh
- kafka-console-consumer.sh
- kafka-group-manager.sh
Correct answer: kafka-consumer-groups.sh
kafka-consumer-groups.sh manages consumer group metadata including listing groups, describing lag, resetting offsets, and deleting groups.
Question 5: What does the `min.insync.replicas` broker/topic setting control?
- The minimum number of replicas a topic must have
- The minimum number of replicas that must acknowledge a write for it to succeed (Correct answer)
- The minimum number of brokers required to start the cluster
- The minimum number of replicas that must be online for leader election
Correct answer: The minimum number of replicas that must acknowledge a write for it to succeed
min.insync.replicas specifies how many ISR replicas must acknowledge a write before the producer receives success, working with acks=all for durability.
Question 6: What is the purpose of the `kafka-reassign-partitions.sh` tool?
- To change the replication factor of existing topics
- To move partition replicas to different brokers (Correct answer)
- To reassign consumer group members to partitions
- To reorder messages within a partition
Correct answer: To move partition replicas to different brokers
kafka-reassign-partitions.sh moves partition replicas across brokers, useful for load rebalancing or safely decommissioning a broker.
Question 7: Which metric best indicates how far behind a Kafka consumer group is from the latest produced messages?
- records-consumed-rate
- fetch-latency-avg
- records-lag-max (Correct answer)
- commit-latency-avg
Correct answer: records-lag-max
records-lag-max reports the maximum number of messages a consumer partition is behind the latest offset, directly measuring consumer lag.
Which command-line tool is used to create, delete, describe, and alter Kafka topics?