Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proper cassandra keyspace restore procedure

I am looking for confirmation that my Cassandra backup and restore procedures are sound and I am not missing anything. Can you please confirm, or tell me if something is incorrect/missing?

Backups:

  • I run daily full backups of the keyspaces I care about, via "nodetool snapshot keyspace_name -t current_timestamp". After the snapshot has been taken, I copy the data to a mounted disk, dedicated to backups, then do a "nodetool clearsnapshot $keyspace_name -t $current_timestamp"
  • I also run hourly incremental backups - executing a "nodetool flush keyspace_name" and then moving files from the backup directory of each keyspace, into the backup mountpoint

Restore:

So far, the only valid way I have found to do a restore (and tested/confirmed) is to do this, on ALL Cassandra nodes in the cluster:

  1. Stop Cassandra
  2. Clear the commitlog *.log files
  3. Clear the *.db files from the table I want to restore
  4. Copy the snapshot/full backup files into that directory
  5. Copy any incremental files I need to (I have not tested with multiple incrementals, but I am assuming I will have to overlay the files, in sequence from oldest to newest)
  6. Start Cassandra
  7. On one of the nodes, run a "nodetool repair keyspace_name"

So my questions are:

  1. Does the above backup and restore strategy seem valid? Are any steps inaccurate or anything missing?
  2. Is there a way to do this without stopping Cassandra on EVERY node? For example, is there a way to restore the data on ONE node, then somehow make it "authoritative"? I tried this, and, as expected, since the restored data is older, the data on the other nodes (which is newer) overwrites in when they sync up during repair.

Thank you!

like image 325
CRCerr0r Avatar asked Apr 04 '14 15:04

CRCerr0r


1 Answers

There's two ways to restore Cassandra backups without restarting C*:

  1. Copy the files into place, then run "nodetool refresh". This has the caveat that the rows will still be older than tombstones. So if you're trying to restore deleted data, it won't do what you want. It also only applies to the local server (you'll want to repair after)
  2. Use "sstableloader". This will load data to all nodes. You'll need to make sure you have the sstables from a complete replica, which may mean loading the sstables from multiple nodes. Added bonus, this works even if the cluster size has changed. I'm not sure if ordering matters here (that is, I don't know if row timestamps are preserved through the load or if they're redefined during load)
like image 82
Elliott Avatar answered Oct 13 '22 09:10

Elliott