Kafka CLI Flashcards
What is the purpose of the kafka-topics.sh CLI script?
To manage Kafka topics, such as creating, deleting, listing, or describing them.
What type of properties does playground.config typically contain?
Connection properties, such as authentication and security settings.
What is the function of the -bootstrap-server option?
Specifies the Kafka broker to connect to.
What is the command to view all topics?
kafka-topics.sh –command-config playground.config –bootstrap-server cluster.playground.cdkt.io:9092 –list
How do you describe a specific topic?
Add the topic name and –describe to the kafka-topics.sh command.
kafka-topics.sh –command-config playground.config –botstrap-server cluster.playground.cdkt.io:9092 –topic first_topic –describe
What is a replication factor in Kafka?
The number of copies of a partition that are maintained across different brokers.
True or False: You can have a higher replication factor than the number of brokers available.
False.
What command is used to delete a topic?
kafka-topics.sh –command-config playground.config –bootstrap-server cluster.playground.cdkt.io:9092 –topic second_topic –delete
What is the purpose of the kafka-console-producer.sh command?
To produce data to a topic.
What happens when you produce to a non-existing topic?
You will get an error unless the command is run in local Kafka, which will create a topic with default config. (replica= 1, partition=1), warning.
Fill in the blank: The command to produce messages with keys is to use the property parse.key set to _______.
true
What does the –property key.separator=: do?
It separates the key and value in produced messages.
How do you consume messages from the tail of the topic?
kafka-console-consumer.sh –consumer.config playground.config –botstrap-server cluster.playground.cdkt.io:9092 –topic second_topic
What is the command to consume messages from the beginning of the topic?
Add –from-beginning to the kafka-console-consumer.sh command.
kafka-console-consumer.sh –consumer.config playground.config –botstrap-server cluster.playground.cdkt.io:9092 –topic second_topic –from-beginning
What does the –group option do in the consumer command?
It specifies that the consumer is part of a consumer group.
What happens if the same consumer group command is run again?
You won’t see any messages because one consumer in that group has already read them.
What command is used to list consumer groups?
kafka-consumer-groups.sh –command-config playground.config –botstrap-server cluster.playground.cdkt.io:9092 –list
What indicates that a consumer is caught up with the newest messages?
When the current-offset and log-end-offset are the same.
What is (consumer) lag?
The difference between the current offset and the log end offset, indicating unread messages.
What does the –dry-run option do when resetting offsets?
It shows what the assignment will be without executing it.
eg.
kafka-consumer-groups.sh –command-config playground.config –botstrap-server cluster.playground.cdkt.io:9092 –group my-first-application –reset-offsets –to-earliest –topic third_topic –dry-run
What must be done to execute the reset offset command?
Switch out –dry-run with –execute and stop the consumer.
kafka-consumer-groups.sh –command-config playground.config –botstrap-server cluster.playground.cdkt.io:9092 –group my-first-application –reset-offsets –to-earliest –topic third_topic –execute
true or false: kafka-console-consumer uses a random group id
true
what flag do you have to use to override the group.id for kafka-console-consumer?
1. –group mygroup
2. –property group.id=mygroup
- –group mygroup
You override by creating a consumer group
What script to I use to perform operations on the consumer offsets?
kafka-consumer-groups