Bird
Raised Fist0

Which of the following is the correct syntax to set log compaction on a Kafka topic using the CLI?

easy📝 Syntax Q3 of Q15
Kafka - Monitoring and Operations
Which of the following is the correct syntax to set log compaction on a Kafka topic using the CLI?
Akafka-topics.sh --create --topic my-topic --compaction enabled --bootstrap-server localhost:9092
Bkafka-topics.sh --alter --topic my-topic --config cleanup.policy=compact --bootstrap-server localhost:9092
Ckafka-configs.sh --set --topic my-topic --property cleanup.policy=compact
Dkafka-console-producer.sh --topic my-topic --config cleanup.policy=compact
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct CLI command for topic config

    To alter topic config, use kafka-topics.sh with --alter and --config flags.
  2. Step 2: Check options

    kafka-topics.sh --alter --topic my-topic --config cleanup.policy=compact --bootstrap-server localhost:9092 uses correct syntax. kafka-topics.sh --create --topic my-topic --compaction enabled --bootstrap-server localhost:9092 uses invalid flag. kafka-configs.sh --set --topic my-topic --property cleanup.policy=compact uses wrong tool. kafka-console-producer.sh --topic my-topic --config cleanup.policy=compact is for producing messages.
  3. Final Answer:

    kafka-topics.sh --alter --topic my-topic --config cleanup.policy=compact --bootstrap-server localhost:9092 -> Option B
  4. Quick Check:

    Correct CLI syntax = kafka-topics.sh with --alter and --config [OK]
Quick Trick: Use kafka-topics.sh --alter with --config cleanup.policy=compact [OK]
Common Mistakes:
MISTAKES
  • Using kafka-console-producer.sh to set configs
  • Using kafka-configs.sh incorrectly for topic configs
  • Wrong flags like --compaction enabled

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes