Importing ZooKeeper offsets
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.
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. A file with the ZooKeeper offset previously exported is needed.
How to do it...
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
How it works...
The preceding command takes the following arguments:
--zkconnect
: This specifies the ZooKeeper connect string. It is a comma-separated list in thehost:port
format.--input-file
: This specifies the file to import ZooKeeper offsets from...