2016-01-20 47 views
1

请帮我解决问题。我使用Ubuntu 14.04,Java 8,Cassandra 2.1.3。对不起,我是初学者。如何从dir提取和反序列化commitLog:/ var/lib/cassandra/commitlog? 据我了解,我们可能会使用lib for Maven cassandra-all,方法CommitLogReplayer.recover在哪里?如果我开始恢复commitLog,例如:Cassandra 2.1.3。如何提取CommitLog

CommitLogReplayer.recover(new File("/var/lib/cassandra/commitlog/CommitLog-4-1453270991708.log")); 

我得到异常:

Expecting URI in variable: [cassandra.config]. Please prefix the file with file:/// for local files or file://<server>/ for remote files. Aborting. If you are executing this from an external tool, it needs to set Config.setClientMode(true) to avoid loading configuration. 
Fatal configuration error; unable to start. See log for stacktrace. 

Config.setClientMode(true); - 不要帮我。

我错了什么?

回答

2

使用setClientMode(true),除非您自己创建cfmetadata,否则将没有上下文来反序列化数据。即使这样,这是一个非常不平凡的项目,因为突变的应用与C *紧密结合。这就是说这不是不可能的,但是你不能使用CommitLogReplayer,因为它试图应用这些突变。它是一个很好的开始寻找自己编写的代码(直到CommitLogReplayer.replayMutation,你可以重复使用)。

+0

谢谢克里斯!如果我理解正确的C * src的标准方法不帮我解决这个任务?我需要用我的解决方案覆盖或重写这些方法? – Javis

+1

正确,如果您尝试检查提交日志的内容,则没有内置任何内容来执行此操作。如果您只想恢复提交日志,请结帐https://docs.datastax.com/en/cassandra/2.1/cassandra/configuration/configLogArchive_t.html。您可以设置还原选项并重新启动节点以在节点上重播它们。 –

+0

感谢您的帮助克里斯!我会考虑换一种解决方案。 – Javis