Dumping log segments
This tool is for debugging the Kafka log data for various purposes, such as reviewing how the logs have been written and to see the status of the segments. Also, it is useful for reviewing the log files generated by Kafka.
Getting ready
For this recipe, Kafka must be installed, ZooKeeper running, broker running and some topics created on it. The topics should have produced some messages and have some consumers created in a consumer group. The point here is to have some information in the Kafka log segments, for debugging, auditing, or back up, as well as for checking log segment health.
How to do it...
- From the Kafka installation directory, run the following command:
$ bin/kafka-run-class.sh kafka.tools.DumpLogSegments --deep-iteration --files /tmp/kafka-logs/your-topic-0/00000000000000000000.log
The output is something like the following:
Dumping /tmp/kafka-logs/source-topic-0/00000000000000000000.logStarting offset: 0 offset: 0 position: 0 CreateTime: 1511661360150 isvalid...