mongorestore 无限期挂起

问题描述 投票:0回答:3

我正在尝试使用 mongorestore 从 gzip 文件中恢复数据库。数据库大小约为 89MB,gzip 文件约为 4.4MB。

但是,还原无限期挂起,没有错误消息。我应该如何解决这个问题?

我运行的命令是:

mongorestore --gzip --archive ./my-db.gz --drop -u admin --authenticationDatabase admin --verbose=5

因此回应是:

2018-01-09T15:47:45.089+0100    standard input is a terminal; reading password from terminal
Enter password:

2018-01-09T15:47:46.508+0100    will listen for SIGTERM, SIGINT, and SIGKILL
2018-01-09T15:47:46.509+0100    checking options
2018-01-09T15:47:46.509+0100        dumping with object check disabled
2018-01-09T15:47:46.527+0100    connected to node type: standalone
2018-01-09T15:47:46.528+0100    standalone server: setting write concern w to 1
2018-01-09T15:47:46.528+0100    using write concern: w='1', j=false, fsync=false, wtimeout=0

在这里,它永远停止。数据库已成功创建,但大小仍为 0b

奇怪的是,MongoDB Compass 中的数据库概览显示数据库中的单个集合有 ~28k 文档,这是我所期望的,平均大小和其他元数据显然是正确的,但无法读取任何内容。

我已经从实时集群导出了数据库,并试图导入我的本地开发环境,通过 Docker 运行单个实例。

我应该从这里去哪里?

谢谢。

mongodb backup mongorestore
3个回答
55
投票

我找到了解决方案。

如果我用 --archive ./my-db.gz 运行命令,我会遇到死锁。如果我这样做 --archive=./my-db.gz,它会正确恢复(即需要等号)。

我正在运行 MacOSX High Sierra (10.13.2),并从 brew 安装了 MongoDB;版本:

mongorestore version: r3.4.1
git version: 4a0fbf5245669b55915adf7547ac592223681fe1
Go version: go1.7.5
   os: darwin
   arch: amd64
   compiler: gc
OpenSSL version: OpenSSL 1.0.2k  26 Jan 2017

4
投票

这似乎是正确的行为,尽管这很奇怪。

引用自docs

要从标准输入恢复,请使用 --archive 选项运行 mongorestore 但省略文件名。

因此程序正在等待将存档通过管道传输到标准输入。

它可以这样工作:

mongorestore --gzip --archive=./my-db.gz --drop -u admin --authenticationDatabase admin --verbose=5

mongorestore --gzip --archive --drop -u admin --authenticationDatabase admin --verbose=5 < my-db.gz

1
投票

对我来说,这该死的东西卡在一个百分比上大约 5 分钟,然后自己增加。不知道为什么:/网络活动很好,磁盘也很好。不确定如何进一步调试。

© www.soinside.com 2019 - 2024. All rights reserved.