由于DocTooLargeForCapped错误,mongorestore失败

时间:2015-07-07 21:49:14

标签: mongodb

我试图像这样恢复一个集合:

$ mongorestore --verbose --db MY_DB --collection MY_COLLECTION /path/to/MY_COLLECTION.bson --port 1234 --noOptionsRestore

这里是错误输出(删除了时间戳):

using write concern: w='majority', j=false, fsync=false, wtimeout=0
checking for collection data in /path/to/MY_COLLECTION.bson
found metadata for collection at /path/to/MY_COLLECTION.metadata.json
reading metadata file from /path/to/MY_COLLECTION.metadata.json
skipping options restoration
restoring MY_DB.MY_COLLECTION from file /path/to/MY_COLLECTION.bson
file /path/to/MY_COLLECTION.bson is 241330 bytes
error: write to oplog failed: DocTooLargeForCapped document doesn't fit in capped collection. size: 116 storageSize:1206976512 @ 28575
error: write to oplog failed: DocTooLargeForCapped document doesn't fit in capped collection. size: 116 storageSize:1206976512 @ 28575
restoring indexes for collection MY_DB.MY_COLLECTION from metadata
Failed: restore error: MY_DB.MY_COLLECTION: error creating indexes for MY_DB.MY_COLLECTION: createIndex error: exception: write to oplog failed: DocTooLargeForCapped document doesn't fit in capped collection. size: 116 storageSize:1206976512 @ 28575

还原的结果是具有正确名称但没有文档的数据库和集合。

操作系统:在Azure VM上运行的Ubuntu 14.04。

我刚解决了自己的问题。见下面的答案。

1 个答案:

答案 0 :(得分:0)

问题似乎是我在副本集PRIMARY成员上使用mongod

一旦我在/etc/mongod.conf中注释掉了以下一行,它就没有问题: replSet=REPL_SET_NAME - > #replSet=REPL_SET_NAME

我假设将正确的副本集名称传递给mongorestore命令(如this question中)也可以,但尚未尝试过。