乐闻世界logo
搜索文章和话题

What command shows all of the topics and offsets of partitions in Kafka?

1个答案

1

In Kafka, the commonly used command to view all topics and their partition offsets is the kafka-topics.sh script, which is included with the Kafka installation. You can use the following command to view details of all topics:

shell
kafka-topics.sh --bootstrap-server <server-address> --list

This command displays all topics in the Kafka cluster. Here, <server-address> refers to the address of the Kafka broker, typically in the format hostname:port.

To view the partitions and current offsets of a specific topic, use the kafka-consumer-groups.sh tool. First, identify the consumer group name, then run:

shell
kafka-consumer-groups.sh --bootstrap-server <server-address> --group <group-name> --describe

This command shows the partition information and offsets for the topics consumed by the specified consumer group. Here, <group-name> refers to the consumer group name.

For example, if you have a Kafka cluster running on your local machine (localhost) at port 9092 with a consumer group named 'test-group', use the following command to view detailed information for the topics consumed by this group:

shell
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group test-group --describe

This will list detailed information, including partitions and offsets, for all topics consumed by 'test-group'.

This covers the steps to view all topics and their partition offsets in Kafka.

2024年7月24日 09:49 回复

你的答案