mongorestore:不知道如何处理文件" /home/path/to/folder/collection1.bson&#34 ;,跳过

时间:2018-04-06 09:22:16

标签: mongodb mongorestore

-I'尝试导入mongodb数据库 - 从mongodb base 版本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

注意:使用其他命令

的结果



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 个答案:

答案 0 :(得分:0)

mongorestore 期望转储文件夹包含具有数据库名称的子文件夹,这些子文件夹又包含 BSON 转储和元数据。您看到的错误是因为它没有找到任何包含 BSON/元数据文件的子目录。

以你的情况为例

mongorestore -vvvv  --nsInclude NEWDBNAME    /home/path/to/folder/

你应该使用下面的命令


mongorestore -vvvv  --nsInclude NEWDBNAME    /home/path/to/

其中“文件夹”将是包含数据库名称转储目录的目录的名称,其中应包含 bson 文件

参考以下链接

Stack Overflow Question Answered on Don't know what to do with file “/”, skipping