Important
MongoDB 8.3 is the latest minor release. Starting with MongoDB 8.2, minor releases are available for on-premises deployments (Community and EA) for specific use cases. For more information, see MongoDB Versioning.MongoDB 8.3是最新的次要版本。从MongoDB 8.2开始,次要版本可用于特定用例的本地部署(社区和EA)。有关更多信息,请参阅MongoDB版本控制。
To install the latest MongoDB version supported for on-premises use, see the installation instructions.要安装支持本地使用的最新MongoDB版本,请参阅安装说明。
Familiarize yourself with the content of this document, including thoroughly reviewing the prerequisites, prior to upgrading to MongoDB 8.2.在升级到MongoDB 8.2之前,请熟悉本文档的内容,包括彻底审查先决条件。
The following steps outline the procedure to upgrade a 以下步骤概述了将副本集成员mongod that is a replica set member from version 8.0 to 8.2.mongod从版本8.0升级到8.2的过程。
If you need guidance on upgrading to 8.2, MongoDB professional services offer major version upgrade support to help ensure a smooth transition without interruption to your MongoDB application.如果您需要升级到8.2的指导,MongoDB专业服务提供主要版本升级支持,以帮助确保顺利过渡到MongoDB应用程序,而不会中断。
Upgrade Recommendations and Checklists升级建议和清单
When upgrading, consider the following:升级时,请考虑以下事项:
Upgrade Version Path升级版本路径
To upgrade an existing MongoDB deployment to 8.2, you must be running a 8.0-series release.要将现有的MongoDB部署升级到8.2,您必须运行8.0系列版本。
To upgrade from a version earlier than the 8.0-series, you must successively upgrade major releases until you have upgraded to 8.0-series. 要从早于8.0系列的版本升级,您必须连续升级主要版本,直到升级到8.0系列。For example, if you are running a 7.0-series, you must upgrade first to 8.0 before you can upgrade to 8.2.例如,如果您运行的是7.0系列,则必须先升级到8.0,然后才能升级到8.2。
Check Driver Compatibility检查驱动程序兼容性
Before you upgrade MongoDB, check that you're using a MongoDB 8.2-compatible driver. Consult the driver documentation for your specific driver to verify compatibility with MongoDB 8.2.在升级MongoDB之前,请检查您是否使用了与MongoDB 8.2兼容的驱动程序。请参阅特定驱动程序的驱动程序文档,以验证与MongoDB 8.2的兼容性。
Upgraded deployments that run on incompatible drivers might encounter unexpected or undefined behavior.在不兼容的驱动程序上运行的升级部署可能会遇到意外或未定义的行为。
Preparedness准备
Before beginning your upgrade, see the Compatibility Changes in MongoDB 8.2 document to ensure that your applications and deployments are compatible with MongoDB 8.2. Resolve the incompatibilities in your deployment before starting the upgrade.在开始升级之前,请参阅MongoDB 8.2中的兼容性更改文档,以确保您的应用程序和部署与MongoDB 8.2兼容。在开始升级之前,请解决部署中的不兼容问题。
Before upgrading MongoDB, always test your application in a staging environment before deploying the upgrade to your production environment.在升级MongoDB之前,请务必在将升级部署到生产环境之前,在测试环境中测试您的应用程序。
Downgrade Consideration降级考虑
You cannot downgrade your deployment's binary version without assistance from support.没有支持人员的帮助,您无法降级部署的二进制版本。
To learn more, see Downgrade 8.2 to 8.0.要了解更多信息,请参阅降级8.2到8.0。
Prerequisites先决条件
All Members Version所有成员版本
All replica set members must be running version 8.0. To upgrade a replica set from 7.0-series and earlier, first upgrade all members of the replica set to the latest 8.0-series release, and then follow the procedure to upgrade from MongoDB 8.0 to 8.2.所有副本集成员都必须运行版本8.0。要从7.0系列和更早版本升级副本集,请首先将副本集的所有成员升级到最新的8.0系列版本,然后按照从MongoDB 8.0升级到8.2的过程进行操作。
Feature Compatibility Version功能兼容性版本
The 8.0 replica set must have 8.0副本集必须将featureCompatibilityVersion set to "8.0".featureCompatibilityVersion设置为"8.0"。
To ensure that all members of the replica set have 为确保副本集的所有成员都将featureCompatibilityVersion set to "8.0", connect to each replica set member and check the featureCompatibilityVersion:featureCompatibilityVersion设置为"8.0",请连接到每个副本集成员并检查featureCompatibilityVersion:
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
All members should return a result that includes 所有成员都应返回包含"featureCompatibilityVersion" : { "version" : "8.0" }."featureCompatibilityVersion" : { "version" : "8.0" }的结果。
To set or update 要设置或更新featureCompatibilityVersion, run the following command on the primary. A majority of the data-bearing members must be available:featureCompatibilityVersion,请在主服务器上运行以下命令。大多数数据承载成员必须可用:
db.adminCommand( { setFeatureCompatibilityVersion: "8.0" , confirm: true } )
For more information, see 有关更多信息,请参阅setFeatureCompatibilityVersion.setFeatureCompatibilityVersion。
Replica Set Member State副本集成员状态
Ensure that no replica set member is in the 通过发出ROLLBACK or RECOVERING state by issuing the replSetGetStatus command:replSetGetStatus命令,确保没有副本集成员处于ROLLBACK或RECOVERING状态:
db.adminCommand( { replSetGetStatus: 1 } )Remove Invalid system.buckets Collections删除无效的system.buckets集合
When you upgrade to 8.3, if you have any 升级到8.3时,如果您有任何不是时间序列集合的system.buckets collections that are not time-series collections, you might need to drop or rename those collections before you upgrade, depending on your 8.0 patch release:system.buckets集合,则可能需要在升级之前drop(丢弃)或rename(重命名)这些集合,具体取决于您的8.0补丁版本:
MongoDB 8.0.5 and laterMongoDB 8.0.5及更高版本You do not need to drop在升级之前,您不需要删除非时间序列集合的system.bucketscollections that aren't time-series collections before you upgrade. However, you must drop or rename them after you complete your upgrade.system.buckets集合。但是,您必须在完成升级后删除或重命名它们。MongoDB 8.0.4 and earlierMongoDB 8.0.4及更早版本You must drop or rename在升级之前,您必须删除或重命名非时间序列集合的system.bucketscollections that aren't time-series collections before you upgrade.system.buckets集合。All在升级到版本8.0.0-8.0.4之前,所有system.bucketscollections must have valid time series options configured before you upgrade to versions 8.0.0 - 8.0.4.system.buckets集合都必须配置有效的时间序列选项。
To determine whether you have 要确定是否有非时间序列集合的system.buckets collections that are not time-series collections, use the db.getCollectionInfos() method with a filter:system.buckets集合,请使用db.getCollectionInfos()方法和筛选器:
db.getCollectionInfos(
{
$and: [
{ name: { $regex: /^system\.buckets/ } },
{ 'options.timeseries': { $exists: false } }
]
}
)Download 8.2 Binaries下载8.2二进制文件
Use a Package Manager使用包管理器
If you installed MongoDB from the MongoDB 如果你从MongoDB apt, yum, dnf, or zypper repositories, you should upgrade to 8.2 using your package manager.apt、yum、dnf或zypper存储库安装了MongoDB,你应该使用包管理器升级到8.2。
Follow the appropriate 8.2 installation instructions for your Linux system. This will involve adding a repository for the new release, then performing the actual upgrade process.按照适用于您的Linux系统的8.2安装说明进行操作。这将涉及为新版本添加一个存储库,然后执行实际的升级过程。
Manually手动地
If you have not installed MongoDB using a package manager, you can manually download the MongoDB binaries from the MongoDB Download Center.如果你没有使用包管理器安装MongoDB,你可以从MongoDB下载中心手动下载MongoDB二进制文件。
See 8.2 installation instructions for more information.有关更多信息,请参阅8.2安装说明。
Upgrade Procedure升级程序
You can upgrade from MongoDB 8.0 to 8.2 using a "rolling" upgrade to minimize downtime by upgrading the members individually while the other members are available.您可以使用“滚动”升级从MongoDB 8.0升级到8.2,通过在其他成员可用时单独升级成员来最大限度地减少停机时间。
Shut down the replica set member.关闭副本集成员。
To shut down the 要关闭mongod process, use mongosh to connect to the replica set member and run the following command:mongod进程,请使用mongosh连接到副本集成员并运行以下命令:
db.adminCommand( { shutdown: 1 } )Upgrade secondary members of the replica set.升级副本集的辅助成员。
Upgrade the secondary members of the replica set one at a time:一次升级一个副本集的secondary成员:
Replace the 8.0 binary with the 8.2 binary.将8.0二进制替换为8.2二进制。Restart the member.重新启动成员。
Step down the replica set primary.逐步关闭主副本集。
Connect 将mongosh to the primary and use rs.stepDown() to step down the primary and force an election of a new primary.mongosh连接到初选,并使用rs.stepDown()退出初选并强制选举新的初选。
Upgrade the primary.升级主服务器。
When 当rs.status() shows that the primary has stepped down and another member has assumed PRIMARY state, upgrade the stepped-down primary:rs.status()显示主服务器已降级,另一个成员已处于PRIMARY状态时,升级降级的主服务器:
Shut down the stepped-down primary and replace the关闭已降级的主二进制文件,并用8.2二进制文件替换mongodbinary with the 8.2 binary.mongod二进制文件。Restart the member.重新启动成员。
Enable backwards-incompatible 8.2 features.启用向后不兼容的8.2功能。
At this point, you can run the 8.2 binaries without the 8.2 features that are incompatible with 8.0.此时,您可以运行8.2二进制文件,而不需要与8.0不兼容的8.2功能。
To enable these 8.2 features, set the feature compatibility version (要启用这些8.2功能,请将功能兼容性版本(FCV) to 8.2. You must also set confirm to true if upgrading to 7.0 or later.FCV)设置为8.2。如果升级到7.0或更高版本,您还必须将confirm设置为true。
Tip
Enabling these backwards-incompatible features can complicate the downgrade process since you must remove any persisted backwards-incompatible features before you downgrade.启用这些向后不兼容的功能可能会使降级过程复杂化,因为在降级之前必须删除任何持久的向后不兼容功能。
It is recommended that after upgrading, you allow your deployment to run without enabling these features for a burn-in period to ensure the likelihood of downgrade is minimal. When you are confident that the likelihood of downgrade is minimal, enable these features.建议升级后,在老化期内允许部署在不启用这些功能的情况下运行,以确保降级的可能性最小。当您确信降级的可能性很小时,启用这些功能。
Tip
Ensure that no initial sync is in progress. Running 确保没有进行初始同步。在初始同步过程中运行setFeatureCompatibilityVersion command while an initial sync is in progress will cause the initial sync to restart.setFeatureCompatibilityVersion命令将导致初始同步重新启动。
On the primary, run the 在主数据库上,运行setFeatureCompatibilityVersion command in the admin database:admin数据库中的setFeatureCompatibilityVersion命令:
db.adminCommand( { setFeatureCompatibilityVersion: "8.2", confirm: true } )
Setting featureCompatibilityVersion (FCV) : "8.2" implicitly performs a 设置featureCompatibilityVersion (FCV) : "8.2"隐式执行replSetReconfig to add the term field to the configuration document and blocks until the new configuration propagates to a majority of replica set members.replSetReconfig,将term字段添加到配置文档中并阻止,直到新配置传播到大多数副本集成员。
This command must perform writes to an internal system collection. If for any reason the command does not complete successfully, you can safely retry the command on the primary as the operation is idempotent.此命令必须对内部系统集合执行写入操作。如果由于任何原因命令未成功完成,您可以在主服务器上安全地重试该命令,因为该操作是幂等的。
Additional Upgrade Procedures其他升级程序
To upgrade a standalone, see Upgrade a Standalone to 8.2.要升级单机版,请参阅将单机版升级到8.2。To upgrade a sharded cluster, see Upgrade a Sharded Cluster to 8.2.要升级分片集群,请参阅将分片集群升级到8.2。