2017-06-16 67 views
-1

恢复集合我有一个vesion 3.4.5的mongorestore无法从压缩BSON

$ mongorestore --version 
mongorestore version: r3.4.5 
git version: 520b8f3092c48d934f0cd78ab5f40fe594f96863 
Go version: go1.7 
    os: linux 
    arch: amd64 
    compiler: gc 
OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016 

因为我没有我的服务器上有足够的磁盘空间,所以我不得不从一个zip恢复我的数据库文件。我尝试相同的命令,如文档中,但它给人的错误,这似乎mongorestore忽略标准输入:

$ zcat threads.bson.zip | mongorestore --db suomi24 --collection threads --verbose 
2017-06-16T23:29:39.377+0300 using write concern: w='1', j=false, fsync=false, wtimeout=0 
2017-06-16T23:29:39.377+0300 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 
2017-06-16T23:29:39.378+0300 using default 'dump' directory 
2017-06-16T23:29:39.378+0300 see mongorestore --help for usage information 
2017-06-16T23:29:39.378+0300 Failed: mongorestore target 'dump' invalid: stat dump: no such file or directory 

的zip文件是〜10GB的大,所以我不能做

$ dump=$(zcat threads.bson.zip);mongorestore --db suomi24 --collection threads < $dump 
zsh: fatal error: out of heap memory 

那么,什么是正确的方法?

+0

也许你应该使用_-- archive_选项或_-- gzip_ – calazans

+0

@calazans所以'mongorestore --help'给出了包含'--gzip'开关的更新文档。现在'mongorestore --db db --collection collection --gzip threads.bson.zip'给出'失败:错误扫描文件系统:文件collection.bson.zip没有.bson扩展名'。对我来说很奇怪,因为它似乎在寻找一个普通的'.bson'文件。 – ziyuang

+0

@calazans哦'mongorestore --gzip'与'mongodump --archive'配对。所以也许我应该再次转储数据库。 – ziyuang

回答

2

而不是你做一个直接转储到BBS和压缩,因为你的数据库是非常大的,我认为如果你让一个转储文件压缩它很容易在其他服务器中恢复它。 你可以像这样做这个转储:

mongodump --archive=threads.bson.gz --gzip --db test
而且你可以像这样恢复:
mongorestore --gzip --archive=threads.bson.gz --db test