Database Manual / Self-Managed Deployments / Administration / Configuration & Maintenance

Upgrade to the Latest Self-Managed Patch Release of MongoDB升级到MongoDB最新的自我管理补丁版本

MongoDB version numbers have the form X.Y.Z where Z refers to the patch release number. MongoDB版本号的格式为X.Y.Z,其中Z表示补丁发布号。Patch releases provide security patches, bug fixes, and new or changed features that generally do not contain any backward breaking changes. Always upgrade to the latest patch release in your release series.补丁版本提供安全补丁、错误修复以及通常不包含任何向后破坏性更改的新功能或更改功能。始终升级到版本系列中的最新补丁版本。

For more information on versioning, including Atlas major and minor upgrades, see MongoDB Versioning.有关版本控制的更多信息,包括Atlas的主要和次要升级,请参阅MongoDB版本控制

About this Task关于此任务

This page describes upgrade procedures for the MongoDB 8.0 release series. To upgrade a different release series, refer to the corresponding version of the manual.本页介绍MongoDB 8.0版本系列的升级过程。要升级其他版本系列,请参阅相应版本的手册。

Before You Begin开始之前

Review the following sections to ensure that your deployment is ready to be upgraded.请查看以下部分,以确保部署已准备好进行升级。

Backup备份

Ensure you have an up-to-date backup of your data set. See Backup Methods for a Self-Managed Deployment.确保数据集有最新的备份。请参阅自我管理部署的备份方法

Compatibility Considerations兼容性注意事项

Consult the following documents for any special considerations or compatibility issues specific to your MongoDB release:有关特定于MongoDB版本的任何特殊注意事项或兼容性问题,请参阅以下文档:

Maintenance Window维护窗口

If your installation includes replica sets, set the upgrade to occur during a predefined maintenance window.如果安装包含副本集,请将升级设置为在预定义的维护窗口期间进行。

Staging Environment Check暂存环境检查

Before you upgrade a production environment, use the procedures in this document to upgrade a staging environment that reproduces your production environment. 在升级生产环境之前,请使用本文档中的过程升级一个复制生产环境的暂存环境。Ensure that your production configuration is compatible with all changes before upgrading.在升级之前,请确保生产配置与所有更改兼容。

Steps步骤

Upgrade each mongod and mongos binary separately. Follow this upgrade procedure:分别升级每个mongodmongos二进制文件。按照以下升级过程操作:

  1. For deployments that use authentication, first upgrade all of your MongoDB Drivers. To upgrade, see the documentation for your driver.对于使用身份验证的部署,首先升级所有MongoDB驱动程序。要升级,请参阅驱动程序的文档
  2. Upgrade any standalone instances. See Upgrade a MongoDB Instance.升级任何独立实例。请参阅升级MongoDB实例
  3. Upgrade any replica sets that are not part of a sharded cluster, as described in Upgrade Replica Sets.按照“升级副本集”中的说明,升级不属于分片群集的任何副本集。
  4. Upgrade sharded clusters, as described in Upgrade Sharded Clusters.升级分片集群,如升级分片群集中所述。

Upgrade a MongoDB Instance升级MongoDB实例

To upgrade a 8.0 mongod or mongos instance, use one of these approaches:要升级8.0 mongodmongos实例,请使用以下方法之一:

  • Upgrade the instance using the operating system's package management tool and the official MongoDB packages. This is the preferred approach. See Install MongoDB.使用操作系统的包管理工具和官方MongoDB包升级实例。这是首选方法。请参阅安装MongoDB
  • Upgrade the instance by replacing the existing binaries with new binaries. See Replace the Existing Binaries.通过用新二进制文件替换现有二进制文件来升级实例。请参阅替换现有二进制文件

Replace the Existing Binaries替换现有二进制文件

This section describes how to upgrade MongoDB by replacing the existing binaries. The preferred approach to an upgrade is to use the operating system's package management tool and the official MongoDB packages, as described in Install MongoDB.本节介绍如何通过替换现有二进制文件来升级MongoDB。升级的首选方法是使用操作系统的包管理工具和官方MongoDB包,如安装MongoDB中所述。

To upgrade a mongod or mongos instance by replacing the existing binaries:要通过替换现有二进制文件来升级mongodmongos实例:

  1. Download the binaries for the latest MongoDB patch release from the MongoDB Download Page and store the binaries in a temporary location. The binaries download as compressed files that uncompress to the directory structure used by the MongoDB installation.MongoDB下载页面下载最新MongoDB补丁版本的二进制文件,并将二进制文件存储在临时位置。二进制文件作为压缩文件下载,解压缩为MongoDB安装使用的目录结构。
  2. Shutdown the instance.关闭实例。
  3. Replace the existing MongoDB binaries with the downloaded binaries.用下载的二进制文件替换现有的MongoDB二进制文件。
  4. Make any required configuration file changes.对配置文件进行任何必要的更改。
  5. Restart the instance.重新启动实例。

Upgrade Replica Sets升级副本集

To upgrade a 8.0 replica set, upgrade each member individually, starting with the secondaries and finishing with the primary. Plan the upgrade during a predefined maintenance window.要升级8.0副本集,请单独升级每个成员,从次要成员开始,到主要成员结束。在预定义的维护窗口期间计划升级。

Important

Before you upgrade or downgrade a replica set, ensure all replica set members are running. If you do not, the upgrade or downgrade will not complete until all members are started.在升级或降级副本集之前,请确保所有副本集成员都在运行。如果不这样做,升级或降级将在所有成员启动之前无法完成。

Upgrade Secondaries升级secondary

Upgrade each secondary separately as follows:按如下方式分别升级每个secondary:

  1. Upgrade the secondary's mongod binary by following the instructions in Upgrade a MongoDB Instance.按照升级MongoDB实例中的说明升级辅助服务器的mongod二进制文件。
  2. After upgrading a secondary, wait for the secondary to recover to the SECONDARY state before upgrading the next instance. 升级辅助服务器后,请等待辅助服务器恢复到SECONDARY状态,然后再升级下一个实例。To check the member's state, issue rs.status() in mongosh.要检查成员的状态,请用mongosh发出rs.status()

    The secondary may briefly go into STARTUP2 or RECOVERING. This is normal. Make sure to wait for the secondary to fully recover to SECONDARY before you continue the upgrade.次级系统可能会短暂进入STARTUP2RECOVERING。这很正常。请确保等待次服务器完全恢复到SECONDARY,然后再继续升级。

Upgrade the Primary升级主

  1. Step down the primary to initiate the normal failover procedure. Using one of the following:关闭主服务器以启动正常的故障转移过程。使用以下方法之一:

    During failover, the set cannot accept writes. Typically this takes 10-20 seconds. Plan the upgrade during a predefined maintenance window.在故障转移期间,该集无法接受写入。这通常需要10-20秒。在预定义的维护窗口期间计划升级。

    Note

    Stepping down the primary is preferable to directly shutting down the primary. Stepping down expedites the failover procedure.关闭主设备比直接关闭主设备更可取。退出可以加快故障转移过程。

  2. Once the primary has stepped down, call the rs.status() method from mongosh until you see that another member has assumed the PRIMARY state.一旦主成员退出,从mongosh调用rs.status()方法,直到你看到另一个成员已经进入PRIMARY状态。
  3. Shut down the original primary and upgrade its instance by following the instructions in Upgrade a MongoDB Instance.按照升级MongoDB实例中的说明关闭原始主服务器并升级其实例。

Upgrade Sharded Clusters升级分片集群

To upgrade a 8.0 sharded cluster:要升级8.0分片集群,请执行以下操作:

  1. Disable the cluster's balancer as described in Disable the Balancer.按照禁用平衡器中的说明禁用集群的平衡器。
  2. Upgrade the config servers.升级配置服务器

    To upgrade the config server replica set, use the procedures in Upgrade Replica Sets.要升级配置服务器副本集,请使用“升级副本集”中的过程。

  3. Upgrade each shard.升级每个分片。

  4. Once the config servers and the shards have been upgraded, upgrade each mongos instance by following the instructions in Upgrade a MongoDB Instance. 升级配置服务器和分片后,按照升级MongoDB实例中的说明升级每个mongos实例。You can upgrade the mongos instances in any order.您可以按任何顺序升级mongos实例。
  5. Re-enable the balancer, as described in Enable the Balancer.按照启用平衡器中的说明重新启用平衡器。

Learn More了解更多