Now we have a backup of the offsets contained in ZooKeeper at some point in time, one can restore them. This tool is handy for restoring the status of the offsets to the point when they were taken.
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. A file with the ZooKeeper offset previously exported is needed.
Let's assume that we have our offset status in the file, /temp/zkoffset.txt
.
From the Kafka installation directory, run the following command:
$ bin/kafka-run-class.sh kafka.tools.ImportZkOffsets --inputfile /tmp/zkoffset.txt --zkconnect localhost:2181