【发布时间】:2020-04-09 15:43:41
【问题描述】:
我正在使用这样的命令从远程机器转储数据:
mongodump --verbose \
--uri="mongodb://mongousr:somepassword@host.domain.com:27017/somedb?authSource=admin" \
--out="$BACKUP_PATH"
这样失败了:
Failed: error writing data for collection `somedb.someCollection` to disk: error reading collection: EOF
somedb.someCollection 大约是 40GB。我没有能力将 RAM 增加到这个大小。
我见过两种解释。一是控制台输出过于冗长并填满了 RAM。这似乎很荒谬,它只有几千字节,而且无论如何它都在客户端计算机上。被拒绝(但我现在用--quiet 再次尝试以确保)。
更合理的解释是主机用somedb.someCollection 数据填充其RAM,然后失败。问题是我看到的“解决方案”是将 RAM 增加到大于集合的大小。
真的吗?这不可能。有这个限制的 mongodump 有什么意义?
问题:是否可以使用比我的 RAM 大小更大的集合来 mongodump 数据库?怎么样?
mongodump 客户端:
macOS
mongodump --version
mongodump version: 4.0.3
git version: homebrew
Go version: go1.11.4
os: darwin
arch: amd64
compiler: gc
OpenSSL version: OpenSSL 1.0.2r 26 Feb 2019
服务器:
built with docker FROM mongo:
Reports: MongoDB server version: 4.0.8
【问题讨论】:
-
为了能够运行
mongodump,不需要拥有比收集数据更多的 RAM。我怀疑您的问题与检测 Docker 部署中的可用 RAM 有关。根据MongoDB Production Notes:If you run mongod in a container (e.g. lxc, cgroups, Docker, etc.) that does not have access to all of the RAM available in a system, you must set storage.wiredTiger.engineConfig.cacheSizeGB to a value less than the amount of RAM available in the container.默认为(可用 RAM -1 GB)的 50%。 -
或者,您可以尝试升级到 MongoDB 4.0.9,其中包括更好地检测容器中的可用 RAM,并且不再需要手动调整
cacheSizeGB设置。