How can I view the data content of a Kafka topic?

To view the data content of a Kafka topic, you can consume and print the data by using the Kafka’s built-in command line tool “Kafka-console-consumer”. Below are the specific steps:

  1. Open the terminal and navigate to the bin folder in the Kafka installation directory.
  2. Use the following command to view the contents of the specified topic:
./kafka-console-consumer.sh --bootstrap-server <kafka服务器地址:端口> --topic <topic名称> --from-beginning

Replace with the actual address and port of the Kafka server, and replace with the name of the topic you want to view.

  1. After executing the command, Kafka-console-consumer will consume the data from the specified topic and print it out.

The Kafka-console-consumer command by default starts consuming data from the latest offset. If you want to start consuming from the earliest data, you can add the parameter “–from-beginning” to the command.

bannerAds