- 我正在尝试导入一个 mongodb 数据库 - 我使用以下命令从 mongodb 基础版本 2.4.10 导出数据库:mongodump -d DBNAME -o / path / folder - 我尝试将转储导入到 mongodb 引擎版本 3.6.3 - 我收到此错误:
root@server:~# mongorestore -vvvv --nsInclude NEWDBNAME /home/path/to/folder/
2018-04-06T10:16:35.729+0200 checking options
2018-04-06T10:16:35.734+0200 dumping with object check disabled
2018-04-06T10:16:35.734+0200 will listen for SIGTERM, SIGINT, and SIGKILL
2018-04-06T10:16:35.927+0200 connected to node type: standalone
2018-04-06T10:16:35.929+0200 standalone server: setting write concern w to 1
2018-04-06T10:16:35.929+0200 using write concern: w='1', j=false, fsync=false, wtimeout=0
2018-04-06T10:16:35.929+0200 mongorestore target is a directory, not a file
2018-04-06T10:16:35.929+0200 preparing collections to restore from
2018-04-06T10:16:35.929+0200 using /home/path/to/folder/ as dump root directory
2018-04-06T10:16:35.952+0200 don't know what to do with file "/home/path/to/folder/collection1.bson", skipping...
2018-04-06T10:16:35.952+0200 don't know what to do with file "/home/path/to/folder/collection1.metadata.json", skipping...
2018-04-06T10:16:35.952+0200 don't know what to do with file "/home/path/to/folder/collection2.bson", skipping...
2018-04-06T10:16:35.953+0200 don't know what to do with file "/home/path/to/folder/collection2.metadata".json", skipping...
2018-04-06T10:16:35.953+0200 don't know what to do with file "/home/path/to/folder/collection3.bson", skipping...
2018-04-06T10:16:35.953+0200 don't know what to do with file "/home/path/to/folder/collection3.metadata".json", skipping...
2018-04-06T10:16:35.953+0200 don't know what to do with file "/home/path/to/folder/collectionX.bson", skipping...
2018-04-06T10:16:35.953+0200 don't know what to do with file "/home/path/to/folder/collectionX.metadata.json", skipping...
.
.
.
2018-04-06T10:16:35.958+0200 finalizing intent manager with multi-database longest task first prioritizer
2018-04-06T10:16:35.958+0200 restoring up to 4 collections in parallel
2018-04-06T10:16:35.958+0200 starting restore routine with id=3
2018-04-06T10:16:35.958+0200 ending restore routine with id=3, no more work to do
2018-04-06T10:16:35.958+0200 starting restore routine with id=0
2018-04-06T10:16:35.958+0200 ending restore routine with id=0, no more work to do
2018-04-06T10:16:35.958+0200 starting restore routine with id=1
2018-04-06T10:16:35.958+0200 ending restore routine with id=1, no more work to do
2018-04-06T10:16:35.959+0200 starting restore routine with id=2
2018-04-06T10:16:35.959+0200 ending restore routine with id=2, no more work to do
2018-04-06T10:16:35.959+0200 done
Result with other command
root@server:~# mongorestore -vvv -d NEWDBName /home/tmp/path/folder/
2018-04-06T10:47:22.949+0200 checking options
2018-04-06T10:47:22.951+0200 dumping with object check disabled
2018-04-06T10:47:22.954+0200 will listen for SIGTERM, SIGINT, and SIGKILL
2018-04-06T10:47:22.963+0200 connected to node type: standalone
2018-04-06T10:47:22.963+0200 standalone server: setting write concern w to 1
2018-04-06T10:47:22.963+0200 using write concern: w='1', j=false, fsync=false, wtimeout=0
**2018-04-06T10:47:22.963+0200 the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead**
2018-04-06T10:47:22.963+0200 mongorestore target is a directory, not a file
2018-04-06T10:47:22.963+0200 building a list of collections to restore from /home/tmp/path/folder dir
2018-04-06T10:47:22.963+0200 reading collections for database DBNAME in folder
2018-04-06T10:47:22.963+0200 found collection DBNAME.collectionX bson to restore to DBNAME.collectionX
2018-04-06T10:47:22.963+0200 found collection metadata from DBNAME.collectionX to restore to DBNAME.collectionX
2018-04-06T10:47:22.963+0200 found collection DBNAME.collectionY bson to restore to DBNAME.collectionY
2018-04-06T10:47:22.963+0200 found collection metadata from DBNAME.collectionY to restore to DBNAME.collectionY
2018-04-06T10:47:22.963+0200 found collection DBNAME.collectionZ bson to restore to DBNAME.collectionZ
2018-04-06T10:47:22.963+0200 found collection metadata from DBNAME.collectionZ to restore to DBNAME.collectionZ
.
.
.
2018-04-06T10:47:22.964+0200 not restoring system.indexes collection because database DBNAME has .metadata.json files
2018-04-06T10:47:22.964+0200 found collection DBNAME.system.users bson to restore to DBNAME.system.users
2018-04-06T10:47:22.964+0200 found collection metadata from DBNAME.system.users to restore to DBNAME.system.users
2018-04-06T10:47:22.964+0200 found collection DBNAME.typeincidents bson to restore to DBNAME.typeincidents
2018-04-06T10:47:22.964+0200 found collection metadata from DBNAME.typeincidents to restore to DBNAME.typeincidents
.
.
.
2018-04-06T10:47:22.964+0200 finalizing intent manager with multi-database longest task first prioritizer
2018-04-06T10:47:22.964+0200 restoring up to 4 collections in parallel
2018-04-06T10:47:22.964+0200 starting restore routine with id=3
2018-04-06T10:47:22.964+0200 starting restore routine with id=0
2018-04-06T10:47:22.964+0200 starting restore routine with id=1
2018-04-06T10:47:22.964+0200 starting restore routine with id=2
2018-04-06T10:47:22.964+0200 reading metadata for DBNAME.evenements from /home/tmp/path/folder/evenements.metadata.json
2018-04-06T10:47:22.964+0200 creating collection DBNAME.evenements using options from metadata
2018-04-06T10:47:22.964+0200 using collection options: bson.D{bson.DocElem{Name:"create", Value:"evenements"}, bson.DocElem{Name:"idIndex", Value:mongorestore.IndexDocument{Options:bson.M{"name":"_id_", "ns":"DBNAME.evenements"}, Key:bson.D{bson.DocElem{Name:"_id", Value:1}}, PartialFilterExpression:bson.D(nil)}}}
2018-04-06T10:47:22.965+0200 Failed: DBNAME.evenements: error creating collection DBNAME.evenements: error running create command: BSON field 'OperationSessionInfo.create' is a duplicate field
感谢帮助
答案1
我刚刚遇到了同样的问题,显然您必须传递--db
和--authenticationDatabase
参数。
身份验证数据库应该是admin
,但我猜他们使用目标数据库,这非常具有误导性。
准备好迎接更多这样的惊喜 - Mongo(及其文档)真的很烂。