Kafka CLI Flashcards

1
Q

What is the purpose of the kafka-topics.sh CLI script?

A

To manage Kafka topics, such as creating, deleting, listing, or describing them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What type of properties does playground.config typically contain?

A

Connection properties, such as authentication and security settings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the function of the -bootstrap-server option?

A

Specifies the Kafka broker to connect to.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the command to view all topics?

A

kafka-topics.sh –command-config playground.config –bootstrap-server cluster.playground.cdkt.io:9092 –list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you describe a specific topic?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a replication factor in Kafka?

A

The number of copies of a partition that are maintained across different brokers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or False: You can have a higher replication factor than the number of brokers available.

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What command is used to delete a topic?

A

kafka-topics.sh –command-config playground.config –bootstrap-server cluster.playground.cdkt.io:9092 –topic second_topic –delete

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose of the kafka-console-producer.sh command?

A

To produce data to a topic.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What happens when you produce to a non-existing topic?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Fill in the blank: The command to produce messages with keys is to use the property parse.key set to _______.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does the –property key.separator=: do?

A

It separates the key and value in produced messages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you consume messages from the tail of the topic?

A

kafka-console-consumer.sh –consumer.config playground.config –botstrap-server cluster.playground.cdkt.io:9092 –topic second_topic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the command to consume messages from the beginning of the topic?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the –group option do in the consumer command?

A

It specifies that the consumer is part of a consumer group.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What happens if the same consumer group command is run again?

A

You won’t see any messages because one consumer in that group has already read them.

17
Q

What command is used to list consumer groups?

A

kafka-consumer-groups.sh –command-config playground.config –botstrap-server cluster.playground.cdkt.io:9092 –list

18
Q

What indicates that a consumer is caught up with the newest messages?

A

When the current-offset and log-end-offset are the same.

19
Q

What is (consumer) lag?

A

The difference between the current offset and the log end offset, indicating unread messages.

20
Q

What does the –dry-run option do when resetting offsets?

A

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

21
Q

What must be done to execute the reset offset command?

A

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

22
Q

true or false: kafka-console-consumer uses a random group id

A

true

23
Q

what flag do you have to use to override the group.id for kafka-console-consumer?
1. –group mygroup
2. –property group.id=mygroup

A
  1. –group mygroup

You override by creating a consumer group

24
Q

What script to I use to perform operations on the consumer offsets?

A

kafka-consumer-groups