mongodump 备份数据时报错 Unrecognized field 'snapshot'

问题

使用 Ubuntu 20.04 apt 安装的 mongodump,备份云上的 MongoDB 服务数据时,报错 Failed: error writing data for collection `xxx_prod_marketdata.marketdata04_xxx.sec` to disk: error reading collection: Failed to parse: { find: "marketdata04_xxx.sec", skip: 0, snapshot: true, $readPreference: { mode: "secondaryPreferred" }, $db: "xxx_prod_marketdata" }. Unrecognized field 'snapshot'.

分析

系统自带的 mongo-tools 版本太低

# mongodump --version
mongodump version: built-without-version-string
git version: built-without-git-spec
Go version: go1.10.1
   os: linux
   arch: amd64
   compiler: gc
OpenSSL version: OpenSSL 1.1.0g  2 Nov 2017

解决办法

卸载掉老版本的 mongo-tools ,安装新版本的 mongodb-database-tools,工具下载页面 https://www.mongodb.com/try/download/database-tools

# apt remove mongo-tools -y
# wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2004-x86_64-100.12.0.deb
# apt install -y ./mongodb-database-tools-ubuntu2004-x86_64-100.12.0.deb
# mongodump --version
mongodump version: 100.12.0
git version: 4558399ef8d5aa59a2779d5909fe9713da43b6af
Go version: go1.23.7
   os: linux
   arch: amd64
   compiler: gc
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容