Martin Bard
Martin Bard

Reputation: 41

Force ZooKeeper to generate snapshot

Is it possible to force ZooKeeper to take a snapshot at a specific time or a specific time interval, Not only via 'snapCount' in ZooKeeper configuration

What I like to do is to schedule a snapshot each day or every 24h. Either that its configured in ZooKeeper or force it via cmdline.

This is to 'rollback' my ZooKeeper to a known state in time, in-case the data gets corrupted or someone adds incorrect information.

Upvotes: 4

Views: 3974

Answers (2)

Nikita Mendelbaum
Nikita Mendelbaum

Reputation: 808

The only method I found to force snapshot is to restart Zookeeper node which makes it to create the new snapshot with the latest data. Quite a good solution if you use an ensemble. At least, you will get the consistence data if you will take both - the snapshot and latest log files (snapshot is fuzzy and using it in complex with transaction logs is strongly recommended). But considering this, forcing the snapshot is not really neccessary, I suppose (you should take log files anyway). Copying log files on active zookeeper is also not a good idea... So stop zookeeper node and copy it's dataDir (with dataLogDir if it's separated) to have guaranteed healthy backup with consistent data for the moment of time when you stopped zk.

Upvotes: 4

JaredC
JaredC

Reputation: 5300

I don't believe Zookeeper internally supports this functionality. However, you can always manually copy the latest snapshot and log files (one each) somewhere for safe keeping. Rolling back to that time is then a matter of copying the files back into the data directory when needed.

Upvotes: 1

Related Questions