2012-12-11 34 views
2

在轉儲/安全目錄messages.bson和messages.medata.json fiels。它應該還原 120,477文檔。 我想從它恢復數據。 我輸入命令:mongodbrestore似乎沒有恢復所有文件

mongorestore -v --db enron --drop dump/enron 

後命令完成我得到一個messagee: 120477對象發現 不知道該怎麼辦的文件[轉儲/安然/ messages.metadata.json]

但在收集消息中,我看到112196個文檔使用:

db.messages.count() 

請問您有什麼問題嗎? 命令的輸出:

c:\mongodb\mongodb-win32-i386-2.0.5\bin>mongorestore -v dump/enron/ 
Tue Dec 11 14:17:39 creating new connection to:127.0.0.1 
Tue Dec 11 14:17:39 BackgroundJob starting: ConnectBG 
Tue Dec 11 14:17:39 connected connection! 
connected to: 127.0.0.1 
Tue Dec 11 14:17:39 dump/enron/messages.bson 
Tue Dec 11 14:17:39  going into namespace [enron.messages] 
Tue Dec 11 14:17:39  file size: 396236668 
       126878231/396236668  32% 
       270206614/396236668  68% 
       375698921/396236668  94% 
       381433738/396236668  96% 
       387378348/396236668  97% 
       394626836/396236668  99% 
120477 objects found 
don't know what to do with file [dump/enron/messages.metadata.json] 

什麼消息:「不知道該怎麼辦的文件[轉儲/安然/ messages.metadata.json]」是什麼意思?

回答

1

您需要在還原bson文件時指定數據庫和集合。

它爲我的作品像這樣:

$ mongodump -d mark --collection coll 
connected to: 127.0.0.1 
DATABASE: mark to  dump/mark 
    mark.coll to dump/mark/coll.bson 
     1000 objects 

$ mongorestore -d mark --collection newcoll dump/mark/ 
    connected to: 127.0.0.1 
    Wed Aug 29 11:48:39 dump/mark/coll.bson 
    Wed Aug 29 11:48:39  going into namespace [mark.newcoll] 
    1000 objects found 

你能嘗試 -

mongorestore -d enron --collection messages /dump/enron/ 
+0

但它將數據複製到正確的集合中,問題是文檔數量不正確。它爲什麼說:「找到120477個對象」;但恢復後只有112196個。在恢復之前,收集中沒有數據。 – Oleg

+0

消息:「不知道如何處理文件[dump/enron/messages.metadata.json]」是什麼意思? – Oleg

+0

很難說不能訪問你的數據,但是,減少的數字表明一些對象沒有被成功導入。這似乎是由於腐敗或結構問題(消息「不知道該做什麼」似乎證實)。你可能會嘗試[bsondump](原始bson文件)並分析它的腐敗。你還可以用'-vvvvv'增加'mongorestore'的詳細程度,以查看是否有更多的記錄。 –

3

這應該工作:

ssharma$ mongorestore -d enron --collection messages /dump/enron/messages.bson 
connected to: 127.0.0.1 
Thu Mar 7 13:05:05 /dump/enron/messages.bson 
Thu Mar 7 13:05:05  going into namespace [enron.messages] 
Thu Mar 7 13:05:09   74234213/396236668 18% (bytes) 
Thu Mar 7 13:05:12   126614885/396236668 31% (bytes) 
Thu Mar 7 13:05:15   192098158/396236668 48% (bytes) 
Thu Mar 7 13:05:18   208083274/396236668 52% (bytes) 
Thu Mar 7 13:05:21   231816712/396236668 58% (bytes) 
Thu Mar 7 13:05:24   293564538/396236668 74% (bytes) 
Thu Mar 7 13:05:27   356071219/396236668 89% (bytes) 
Thu Mar 7 13:05:30   379387449/396236668 95% (bytes) 
120477 objects found 
Thu Mar 7 13:05:32  Creating index: { key: { _id: 1 }, ns: "enron.messages", name: "_id_" } 
ssharma$ ./mongo 
MongoDB shell version: 2.2.2 
connecting to: test 
> use enron 
switched to db enron 
> db.messages.count() 
120477