2016-01-20 42 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