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