2015-02-06 61 views
0

恢復mongodump後後空集,我做mongorestore這似乎做工精細MongoDB中仍然顯示了轉儲

heathers-air:db heathercohen$ mongorestore -v -host localhost:27017 
2015-02-06T11:22:40.027-0800 creating new connection to:localhost:27017 
2015-02-06T11:22:40.028-0800 [ConnectBG] BackgroundJob starting: ConnectBG 
2015-02-06T11:22:40.028-0800 connected to server localhost:27017 (127.0.0.1) 
2015-02-06T11:22:40.028-0800 connected connection! 
connected to: localhost:27017 
2015-02-06T11:22:40.030-0800 dump/langs.bson 
2015-02-06T11:22:40.030-0800 going into namespace [dump.langs] 
Restoring to dump.langs without dropping. Restored data will be inserted without raising errors; check your server log 
file dump/langs.bson empty, skipping 
2015-02-06T11:22:40.030-0800 Creating index: { key: { _id: 1 }, name: "_id_", ns: "dump.langs" } 
2015-02-06T11:22:40.031-0800 dump/tweets.bson 
2015-02-06T11:22:40.031-0800 going into namespace [dump.tweets] 
Restoring to dump.tweets without dropping. Restored data will be inserted without raising errors; check your server log 
    file size: 4877899 
30597 objects found 
2015-02-06T11:22:41.883-0800 Creating index: { key: { _id: 1 }, name: "_id_", ns: "dump.tweets" } 

當我嘗試雖然訪問數據,它仍然是空的,之前看的方式恢復:

> show dbs 
admin (empty) 
dump  0.078GB 
local 0.078GB 
tweets (empty) 
twitter (empty) 

它說它發現了30597個物體,他們去了哪裏?

+0

輸出狀態爲「已恢復的數據將被插入而不會引起錯誤;請檢查您的服務器日誌」。當時你檢查了mongod.log文件是否有錯誤? – 2015-02-06 20:12:16

+0

它讀取 '2015-02-06T11:23:31.847-0800 [initandlisten]連接從127.0.0.1:52475#21接受(現在打開6個連接) 2015-02-06T11:23:55.287-0800 [clientcursormon] mem(MB)res:18 virt:2803 2015-02-06T11:23:55.287-0800 [clientcursormon] mapped(incl journal view):320 2015-02-06T11:23:55.287-0800 [clientcursormon] connections: 6 2015-02-06T11:27:13.555-0800 [conn21]結束連接127.0.0.1:52475(現在打開5個連接)' @JamesWahlin – 2015-02-06 21:45:50

+1

您可以使用「use dump」切換到mongo shell中的轉儲數據庫嗎?然後運行「顯示集合」併發布結果? – 2015-02-06 23:47:03

回答

0

他們進入轉儲數據庫,然後進入收集dump.tweetsdump.langs。文件包含在文件夾dump中的事實意味着mongorestore認爲它們應該還原到數據庫dump(它是從路徑推斷的)。詳細輸出甚至明確指出數據正在被放入dump.langsdump.tweets中。

如果您指定要還原到的數據庫(使用-d)並還原特定文件,您將能夠將文檔還原到所需的數據庫。或者,您只需運行以下代碼即可查看轉儲數據庫:

use dump; 
db.tweets.find(); 
db.langs.find();