DBAtlas · 数据库运维图谱

检查 featureCompatibilityVersion(fCV)和大版本升级顺序

MongoDB升级

命令

// 1) Current fCV (must be the same on all members; targetVersion appears if a transition is incomplete):
db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 })
// 2) Upgrade binaries in a rolling fashion (secondaries -> stepDown -> old primary); fCV stays old
db.version()
// 3) After the observation period, raise fCV on the primary (on mongos in a sharded cluster):
db.adminCommand({ setFeatureCompatibilityVersion: "7.0", confirm: true })
// 4) If a rollback is needed, fCV is lowered BEFORE the binaries:
db.adminCommand({ setFeatureCompatibilityVersion: "6.0", confirm: true })

作用

显示当前的 fCV;给出二进制升级和 fCV 升级这两个独立步骤的执行顺序。

适用场景

规划大版本升级(如 6.0 -> 7.0)、升级后无法使用新功能,或升级到下一个大版本之前。

注意

大版本不能跳过:从 5.0 -> 7.0 需先升级到 6.0 并将 fCV 设为 6.0。提高 fCV 后数据文件可能切换为新格式,二进制降级会更困难;仅在新版本平稳运行几天后再提高 fCV。7.0+ Community 不正式支持二进制降级;回退方案应基于备份。升级前检查驱动兼容性。

在 DBAtlas 中打开 →