【问题标题】:MongoDB, mongorestore: "Can only replay oplog on full restore"MongoDB,mongorestore:“只能在完全恢复时重放 oplog”
【发布时间】:2014-05-14 00:19:04
【问题描述】:

我在恢复转储和在 MongoDB 上重放 oplog 时遇到了一些麻烦。

我必须重播 oplog 到某个时间点,因此发出以下命令:

mongorestore --port <n> --db <name> --oplogReplay --oplogLimit <ts> <dumpfile>

但 mongorestore 回复“只能在完全恢复时重放 oplog”。

Looking at the source code 似乎在用户未指定 --db 选项时会显示此错误消息,但我指定了。

你知道还有什么原因吗?

【问题讨论】:

    标签: mongodb mongodump mongorestore


    【解决方案1】:

    我认为这是相反的问题 - 使用 oplog 选项时不能指定数据库。你找到的代码:

     if (mongoRestoreGlobalParams.oplogReplay) {
                // fail early if errors
    
                if (toolGlobalParams.db != "") {
                    toolError() << "Can only replay oplog on full restore" << std::endl;
                    return -1;
                }
    

    当您同时指定 oplogReplay 和数据库时触发。

    请记住,oplog 是针对整个 mongodb 实例的,而不是针对特定数据库的。我相信使用 --oplog 进行 mongodump 会转储整个实例,因此不能将其重新加载到一个数据库中。

    它的文档记录很差。 Mongolab 在他们的文档中提到了这一点:

    Point-in-time method
    
    Applicable to Dedicated plans only
    
    If you have a Dedicated plan, you can take server-wide mongodumps to export all of the databases on the server.
    
    This method is useful because it allows you to use the the --oplog and --oplogReplay options to mongodump and mongorestore (respectively). The options allow for a point-in-time snapshot of the server by also including the oplog in the dump. This oplog is then replayed when you use the --oplogReplay option upon restore.
    

    但不是很清楚。

    【讨论】:

    • 是的,代码确实如此。我想在凌晨 2 点,我太累了,无法阅读它。现在 mongorestore 告诉我转储没有使用 --oplog 标志,我猜还有其他问题。谢谢你的回答!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-19
    • 1970-01-01
    • 1970-01-01
    • 2012-02-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多