我不小心在Cassandra中截断了一张桌子。我想知道是否有任何工具可用于恢复其中的数据。任何帮助,将不胜感激。感谢。
答案 0 :(得分:4)
auto_snapshot(默认值:true)
Cassandra是否拍摄快照 截断键空间或删除表之前的数据。阻止 数据丢失,DataStax强烈建议使用默认设置。如果你 将auto_snapshot设置为false,截断或丢弃时会发生数据丢失。
(摘自https://docs.datastax.com/en/cassandra/3.0/cassandra/configuration/configCassandra_yaml.html)
如果运气好的话,请查看旧sstables的快照目录。对于恢复,他们“只”需要复制回原来的位置。
以下是发生的事情:
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/backups
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/mc-1-big-Data.db
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/mc-1-big-Index.db
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/mc-1-big-Filter.db
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/mc-1-big-Summary.db
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/mc-1-big-Digest.crc32
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/mc-1-big-CompressionInfo.db
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/mc-1-big-Statistics.db
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/mc-1-big-TOC.txt
然后我发出TRUNCATE demokeyspace.demo
- 之后就是这样:
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/backups
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/snapshots
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/snapshots/truncated-1527228644868-demo
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/snapshots/truncated-1527228644868-demo/mc-1-big-Summary.db
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/snapshots/truncated-1527228644868-demo/mc-1-big-TOC.txt
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/snapshots/truncated-1527228644868-demo/mc-1-big-Digest.crc32
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/snapshots/truncated-1527228644868-demo/mc-1-big-Filter.db
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/snapshots/truncated-1527228644868-demo/mc-1-big-CompressionInfo.db
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/snapshots/truncated-1527228644868-demo/mc-1-big-Index.db
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/snapshots/truncated-1527228644868-demo/mc-1-big-Data.db
./data1/demokeyspace/demo-0d1a38b05fe211e8875d13cbb58d64f2/snapshots/truncated-1527228644868-demo/mc-1-big-Statistics.db
只需复制这些文件即可。但请记住,您需要在所有节点上执行此操作,然后运行nodetool refresh demokeyspace demo
以重新读取表(当然还有您的键空间和列家族)。