問題
使用 Ubuntu 20.04 apt 安裝的 mongodump,備份云上的 MongoDB 服務(wù)數(shù)據(jù)時,報錯 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'.
分析
系統(tǒng)自帶的 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