【问题标题】:MongoDB still shows empty collections after restoring from dump从转储恢复后,MongoDB 仍然显示空集合
【发布时间】:2015-02-06 19:35:02
【问题描述】:

在 mongodump 之后,我做了 mongorestore,它似乎工作正常

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 个物体,它们去哪儿了?

【问题讨论】:

  • 输出状态“将插入恢复的数据而不会引发错误;检查您的服务器日志”。您当时检查 mongod.log 文件是否有错误?
  • 它读作2015-02-06T11:23:31.847-0800 [initandlisten] connection accepted from 127.0.0.1:52475 #21 (6 connections now open) 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] end connection 127.0.0.1:52475 (5 connections now open)@JamesWahlin
  • 你可以使用“use dump”切换到mongo shell中的dump数据库,然后运行“show collections”并发布结果吗?

标签: mongodb pymongo mongorestore


【解决方案1】:

他们进入转储数据库,然后进入集合dump.tweetsdump.langs。文件包含在文件夹dump 中的事实意味着mongorestore 认为应该将它们恢复到数据库dump(它是从路径推断的)。详细的输出甚至明确指出数据正在被放入 dump.langsdump.tweets

如果您指定要还原到的数据库(使用-d)并还原特定文件,您将能够将文档还原到所需的数据库。或者,您可以通过运行简单地查看转储数据库:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-27
    • 1970-01-01
    • 2019-11-05
    • 2020-04-01
    • 1970-01-01
    • 2019-02-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多