我正在尝试将 MongoDB 集合从远程服务器转储到本地JSON 文件。
首先,我先进行一些 ssh 端口转发:
ssh -NL 12345:localhost:27017 $REMOTE_USERNAME@$REMOTE_HOST &
然后,出口本身:
mongoexport -h $MONGODB_URL -d $MONGODB_DBNAME -c $MONGODB_COLLECTION -o $BACKUP_FILE --pretty
我通常会得到的是这样的:
2019-02-07T14:58:15.322-0400 writing bubeIO.requests to
2019-02-07T14:58:18.754-0400 [........................] bubeIO.requests 0/2773 (0.0%)
2019-02-07T14:58:21.754-0400 [........................] bubeIO.requests 10/2773 (0.3%)
2019-02-07T14:58:24.754-0400 [........................] bubeIO.requests 20/2773 (0.6%)
...
...
2019-02-07T14:59:00.754-0400 [........................] bubeIO.requests 2773/2773 (100.0%)
但是,我得到的是:
2019-02-07T14:58:15.322-0400 writing bubeIO.requests to
2019-02-07T14:58:18.754-0400 [........................] bubeIO.requests 0/2773 (0.0%)
2019-02-07T14:58:21.754-0400 [........................] bubeIO.requests 0/2773 (0.0%)
2019-02-07T14:58:24.754-0400 [........................] bubeIO.requests 0/2773 (0.0%)
2019-02-07T14:58:27.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:30.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:33.754-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:36.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:39.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:42.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:45.754-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:48.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:51.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:54.754-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:57.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:59:00.594-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:59:00.594-0400 Failed: error writing data for collection `bubeIO.requests` to disk: error reading collection: read tcp [::1]:61276->[::1]:12345: use of closed network connection
正如您所看到的,它从 0 到 101 非常快,然后它不会从那里到任何地方,直到超时。
之前它在远程转储方面运行良好,但突然之间开始出现这种情况。本地转储工作正常,所以这可能是网络问题?
谁能告诉我如何解决这个问题?
PS:mongod和mongoexport都是4.0.2版本
编辑
在我释放了总共 13 GB 的硬盘空间后,它又开始工作了。也许磁盘无法容纳整个未压缩的集合,所以我对 mongoexport 的内部工作和磁盘使用情况越来越深入。感谢@priyanka-kariya 和@Stennie。
请检查目标机器上的磁盘空间