技术文章 T2 CodyZhang ‘s tips’ : Mongodb Restore 错误: 参数问题 --drop

codyzhang · 发布于 2019年8月20日 · 36 次阅读
96

时间:2019/08

Error log:

E11000 duplicate key error collection: accounts.users index: _id_ dup key: { : ObjectId('5c08e980006ad1816f94caf0') }
 - E11000 duplicate key error collection: accounts.users index: _id_ dup key: { : ObjectId('5c08e980006ad1816f94caf1') }
 - E11000 duplicate key error collection: accounts.users index: _id_ dup key: { : ObjectId('5c08e980006ad1816f94caf2') }
 - E11000 duplicate key error collection: accounts.users index: _id_ dup key: { : ObjectId('5c08e980006ad1816f94caf3') }
 - E11000 duplicate key error collection: accounts.users index: _id_ dup key: { : ObjectId('5c08e980006ad1816f94caf4') }
 - E11000 duplicate key error collection: accounts.users index: _id_ dup key: { : ObjectId('5c08e980006ad1816f94caf5') }
 - E11000 duplicate key error collection: accounts.users index: _id_ dup key: { : ObjectId('5c08e980006ad1816f94caf6') }
 - E11000 duplicate key error collection: accounts.users index: _id_ dup key: { : ObjectId('5c08e980006ad1816f94caf7') }
 - E11000 duplicate key error collection: accounts.users index: _id_ dup key: { : ObjectId('5c08e980006ad1816f94caf8') }
 - E11000 duplicate key error collection: accounts.users index: _id_ dup key: { : ObjectId('5c08e980006ad1816f94caf9') }
 - E11000 duplicate key error collection: accounts.users index: _id_ dup key: { : ObjectId('5c08e980006ad1816f94cafa') }

Analysis:

主要是恢复数据时默认是追加方式的,若是数据已经存在会有错误。 所以我们选择参数:--drop (不要轻易用,因这个参数会先删除已有数据再恢复)

usr/local/mongodb/bin/mongorestore  --drop  opt/mongodb_bak/mongodb_bak_now/

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册