> This page location: /docs.md > /docs/management.md > /docs/manual/administration/self-managed-configuration-and-maintenance.md

> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# Upgrade to the Latest Self-Managed Patch Release of MongoDB

For general guidance on MongoDB version numbering, patch release policy, and upgrade paths, see [MongoDB Versions and Upgrade Paths.](https://www.mongodb.com/docs/mongodb-versions.md#std-label-versions-and-upgrade-paths)

## About this Task

This page describes upgrade procedures for the MongoDB 9.0 release series. To upgrade a different release series, refer to the corresponding version of the manual.

## 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.](https://www.mongodb.com/docs/manual/core/backups.md#std-label-backup-methods)

### Compatibility Considerations

Consult the following documents for any special considerations or compatibility issues specific to your MongoDB release:

- [Release notes](https://www.mongodb.com/docs/manual/release-notes.md#std-label-server-release-notes-landing)

- [Driver documentation](https://www.mongodb.com/docs/drivers/)

### Maintenance Window

If your installation includes [replica sets](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-replica-set), 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`](https://www.mongodb.com/docs/manual/reference/program/mongod.md#mongodb-binary-bin.mongod) and [`mongos`](https://www.mongodb.com/docs/manual/reference/program/mongos.md#mongodb-binary-bin.mongos) binary separately:

1. For deployments that use authentication, first upgrade all of your MongoDB Drivers. To upgrade, see the [documentation for your driver.](https://www.mongodb.com/docs/drivers/)

2. Upgrade any standalone instances. See [Upgrade a MongoDB Instance.](https://www.mongodb.com/docs/manual/tutorial/upgrade-revision.md#std-label-upgrade-mongodb-instance)

3. Upgrade any replica sets that are not part of a sharded cluster, as described in [Upgrade Replica Sets.](https://www.mongodb.com/docs/manual/tutorial/upgrade-revision.md#std-label-upgrade-replica-set)

4. Upgrade sharded clusters, as described in [Upgrade Sharded Clusters.](https://www.mongodb.com/docs/manual/tutorial/upgrade-revision.md#std-label-upgrade-sharded-cluster)

### Check Feature Compatibility Version (FCV)

Before upgrading the binaries, confirm that the `featureCompatibilityVersion` has been fully upgraded on all relevant components of your deployment. If the prior FCV upgrade did not complete successfully, restarting the binary with a higher version can cause the node to crash.

For [Replica Sets:](https://www.mongodb.com/docs/manual/tutorial/upgrade-revision.md#std-label-upgrade-replica-set)

To verify the FCV, connect to each member of the replica set and run the following command:

```javascript
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
```

All members return a result that includes the following:

```javascript
"featureCompatibilityVersion" : { "version" : "9.0" }
```

For [Sharded Clusters:](https://www.mongodb.com/docs/manual/tutorial/upgrade-revision.md#std-label-upgrade-sharded-cluster)

Perform the same check on all config servers and shards:

- For shards that are replica sets, verify FCV on each member of the replica set.

- For standalone shard instances, run the command directly on the instance.

Wait for all members to report the required FCV before proceeding with the binary upgrade.

### Upgrade a MongoDB Instance

To upgrade a 9.0 [`mongod`](https://www.mongodb.com/docs/manual/reference/program/mongod.md#mongodb-binary-bin.mongod) or [`mongos`](https://www.mongodb.com/docs/manual/reference/program/mongos.md#mongodb-binary-bin.mongos) instance, use one of these approaches:

- Upgrade the instance using the operating system's package management tool and the official MongoDB packages. This is the preferred approach. See [Install MongoDB Community and Enterprise Editions.](https://www.mongodb.com/docs/manual/installation.md#std-label-tutorials-installation)

- Upgrade the instance by replacing the existing binaries with new binaries. See [Replace the Existing Binaries.](https://www.mongodb.com/docs/manual/tutorial/upgrade-revision.md#std-label-upgrade-replace-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 Community and Enterprise Editions.](https://www.mongodb.com/docs/manual/installation.md#std-label-tutorials-installation)

To upgrade a [`mongod`](https://www.mongodb.com/docs/manual/reference/program/mongod.md#mongodb-binary-bin.mongod) or [`mongos`](https://www.mongodb.com/docs/manual/reference/program/mongos.md#mongodb-binary-bin.mongos) instance by replacing the existing binaries:

1. Download the binaries for the latest MongoDB patch release from the [MongoDB Download Page](https://www.mongodb.com/try/download/community) 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.

2. Shutdown the instance.

3. Replace the existing MongoDB binaries with the downloaded binaries.

4. Make any required configuration file changes.

5. Restart the instance.

### Upgrade Replica Sets

To upgrade a 9.0 replica set, upgrade each member individually, starting with the [secondaries](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-secondary) and finishing with the [primary](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-primary). Plan the upgrade during a predefined maintenance window.

**Important:**

Before you upgrade or downgrade a cluster, ensure all cluster members are running. If you do not, the upgrade or downgrade will not complete until all members are started.

#### Upgrade Secondaries

Upgrade each secondary separately as follows:

1. Upgrade the secondary's [`mongod`](https://www.mongodb.com/docs/manual/reference/program/mongod.md#mongodb-binary-bin.mongod) binary by following the instructions in [Upgrade a MongoDB Instance.](https://www.mongodb.com/docs/manual/tutorial/upgrade-revision.md#std-label-upgrade-mongodb-instance)

2. After upgrading a secondary, wait for the secondary to recover to the `SECONDARY` state before upgrading the next instance. To check the member's state, issue [`rs.status()`](https://www.mongodb.com/docs/manual/reference/method/rs.status.md#mongodb-method-rs.status) in [`mongosh`.](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh)

   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.

#### Upgrade the Primary

1. Step down the primary to initiate the normal [failover](https://www.mongodb.com/docs/manual/core/replica-set-elections.md#std-label-replica-set-elections) procedure. Using one of the following:

   - The [`rs.stepDown()`](https://www.mongodb.com/docs/manual/reference/method/rs.stepdown.md#mongodb-method-rs.stepDown) helper in [`mongosh`.](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh)

   - The [`replSetStepDown`](https://www.mongodb.com/docs/manual/reference/command/replsetstepdown.md#mongodb-dbcommand-dbcmd.replSetStepDown) database command.

   During failover, the set cannot accept writes. Typically this takes 10-20 seconds. Plan the upgrade during a predefined maintenance window.

   **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()`](https://www.mongodb.com/docs/manual/reference/method/rs.status.md#mongodb-method-rs.status) method from [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh) until you see that another member has assumed the `PRIMARY` state.

3. Shut down the original primary and upgrade its instance by following the instructions in [Upgrade a MongoDB Instance.](https://www.mongodb.com/docs/manual/tutorial/upgrade-revision.md#std-label-upgrade-mongodb-instance)

### Upgrade Sharded Clusters

To upgrade a 9.0 sharded cluster:

1. Disable the cluster's balancer as described in [Disable the Balancer.](https://www.mongodb.com/docs/manual/tutorial/manage-sharded-cluster-balancer.md#std-label-sharding-balancing-disable-temporarily)

2. Upgrade the [config servers.](https://www.mongodb.com/docs/manual/core/sharded-cluster-config-servers.md#std-label-sharding-config-server)

   To upgrade the config server replica set, use the procedures in [Upgrade Replica Sets.](https://www.mongodb.com/docs/manual/tutorial/upgrade-revision.md#std-label-upgrade-replica-set)

3. Upgrade each shard.

   - If a shard is a replica set, upgrade the shard using the procedure titled [Upgrade Replica Sets.](https://www.mongodb.com/docs/manual/tutorial/upgrade-revision.md#std-label-upgrade-replica-set)

   - If a shard is a standalone instance, upgrade the shard using the procedure titled [Upgrade a MongoDB Instance.](https://www.mongodb.com/docs/manual/tutorial/upgrade-revision.md#std-label-upgrade-mongodb-instance)

4. Once the config servers and the shards have been upgraded, upgrade each [`mongos`](https://www.mongodb.com/docs/manual/reference/program/mongos.md#mongodb-binary-bin.mongos) instance by following the instructions in [Upgrade a MongoDB Instance](https://www.mongodb.com/docs/manual/tutorial/upgrade-revision.md#std-label-upgrade-mongodb-instance). You can upgrade the [`mongos`](https://www.mongodb.com/docs/manual/reference/program/mongos.md#mongodb-binary-bin.mongos) instances in any order.

5. Re-enable the balancer, as described in [Enable the Balancer.](https://www.mongodb.com/docs/manual/tutorial/manage-sharded-cluster-balancer.md#std-label-sharding-balancing-re-enable)

## Learn More

- [Production Notes for Self-Managed Deployments](https://www.mongodb.com/docs/manual/administration/production-notes.md#std-label-production-notes)

- [View Cluster Configuration](https://www.mongodb.com/docs/manual/tutorial/view-sharded-cluster-configuration.md#std-label-sharding-manage-shards)

- [Replica Set Data Synchronization](https://www.mongodb.com/docs/manual/core/replica-set-sync.md#std-label-replica-set-sync)
