Kafka Topics CLI
Kafka Topics CLI, i.e., kafka-topics is used to create, delete, describe, or change a topic in Kafka.
References
Flashcards
From the CLI, create people topic with 3 paritions and replication factor of 1:: kafka-topics --bootstrap-server localhost:9092 --create --topic people --replication-factor 1 --partitions 3
From the CLI, list topics:: kafka-topics --bootstrap-server localhost:9092 --list
From the CLI, describe people topic:: kafka-topic --bootstrap-server localhost:9092 --describe --topic people
From the CLI, create a topic people.promotions with configuration compact clean up policy partition count of 1, replication factor of 1, configuration retention of 6 minutes:: kafka-topics --bootstrap-server localhost:9092 --create --topic people.promotions --partitions 1 --replication-factor 1 --config retention.ms=360000 --config cleanup.policy=compact
How will you find out all the partitions where one or more of the replicas for the partition are not in-sync with the leader?:: kafka-topics.sh --zookeeper localhost:2181 --describe --under-replicated-partitions
How will you find out all the unavailable partitions?:: kafka-topics.sh --zookeeper localhost:2181 --describe --unavailable-partitions Please note that as of Kafka 2.2, the --zookeeper option is deprecated and you can now use: kafka-topics.sh --bootstrap-server localhost:9092 --describe --unavailable-partitions
How do you create a topic named test with 3 partitions and 3 replicas using the Kafka CLI?:: bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 3 --partitions 3 --topic test