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

# Upgrade a Replica Set to 8.0

Familiarize yourself with the content of this document, including thoroughly reviewing the prerequisites, prior to upgrading to MongoDB 8.0.

MongoDB 8.0 introduces significant performance improvements from MongoDB 7.0, including, but not limited to:

- Up to 36% better read throughput.

- Up to 32% better performance for typical web applications.

- Up to 20% faster concurrent writes during replication.

**Note:**

The amount of performance improvement can vary depending on the configuration of your workloads and database instances.

To learn more, see [Performance Improvements.](https://www.mongodb.com/docs/manual/release-notes/8.0.md#std-label-8.0-performance-improvements)

The following steps outline the procedure to upgrade a [`mongod`](https://www.mongodb.com/docs/manual/reference/program/mongod.md#mongodb-binary-bin.mongod) that is a replica set member from version 7.0 to 8.0.

If you need guidance on upgrading to 8.0, [MongoDB professional services](https://www.mongodb.com/products/consulting) offer major version upgrade support to help ensure a smooth transition without interruption to your MongoDB application.

## Upgrade Recommendations and Checklists

When upgrading, consider the following:

### Upgrade Version Path

To upgrade an existing MongoDB deployment to 8.0, you must be running a 7.0-series release.

To upgrade from a version earlier than the 7.0-series, you must successively upgrade major releases until you have upgraded to 7.0-series. For example, if you are running a 6.0-series, you must [upgrade first to 7.0](https://www.mongodb.com/docs/manual/release-notes/7.0.md#std-label-7.0-upgrade) *before* you can upgrade to 8.0.

### Check Driver Compatibility

Before you upgrade MongoDB, check that you're using a MongoDB 8.0-compatible driver. Consult the [driver documentation](https://www.mongodb.com/docs/drivers/) for your specific driver to verify compatibility with MongoDB 8.0.

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](https://www.mongodb.com/docs/manual/release-notes/8.2-compatibility.md#std-label-8.2-compatibility) document to ensure that your applications and deployments are compatible with MongoDB 8.0. Resolve the incompatibilities in your deployment before starting the upgrade.

Before upgrading MongoDB, always test your application in a staging environment before deploying the upgrade to your production environment.

### Downgrade Consideration

Starting in MongoDB 8.3, you can downgrade your MongoDB version to the immediately previous minor or major version.

MongoDB only supports single-version downgrades. You cannot downgrade to a release that is multiple versions behind your current release.

For example, you can downgrade a 8.0-series to a 7.0-series deployment. However, further downgrading that 7.0-series deployment to a 6.0-series deployment is not supported.

To learn more, see [Downgrade 8.0 to 7.0.](https://www.mongodb.com/docs/manual/release-notes/8.0-downgrade.md#std-label-8.0-downgrade)

## Prerequisites

### All Members Version

All replica set members must be running version 7.0. To upgrade a replica set from 6.0-series and earlier, *first* [upgrade all members of the replica set to the latest 7.0-series release](https://www.mongodb.com/docs/manual/release-notes/7.0-upgrade-replica-set.md#std-label-7.0-upgrade-replica-set), and then follow the procedure to upgrade from MongoDB 7.0 to 8.0.

### Feature Compatibility Version

The 7.0 replica set must have `featureCompatibilityVersion` set to `"8.3"`.

To ensure that all members of the replica set have `featureCompatibilityVersion` set to `"8.3"`, connect to each replica set member and check the `featureCompatibilityVersion`:

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

All members should return a result that includes `"featureCompatibilityVersion" : { "version" : "7.0" }`.

To set or update `featureCompatibilityVersion`, run the following command on the primary. A majority of the data-bearing members must be available:

```javascript
db.adminCommand( { setFeatureCompatibilityVersion: "7.0" , confirm: true } )
```

For more information, see [`setFeatureCompatibilityVersion`.](https://www.mongodb.com/docs/manual/reference/command/setfeaturecompatibilityversion.md#mongodb-dbcommand-dbcmd.setFeatureCompatibilityVersion)

### Replica Set Member State

Ensure that no replica set member is in the [`ROLLBACK`](https://www.mongodb.com/docs/manual/reference/replica-states.md#mongodb-replstate-replstate.ROLLBACK) or [`RECOVERING`](https://www.mongodb.com/docs/manual/reference/replica-states.md#mongodb-replstate-replstate.RECOVERING) state by issuing the [`replSetGetStatus`](https://www.mongodb.com/docs/manual/reference/command/replsetgetstatus.md#mongodb-dbcommand-dbcmd.replSetGetStatus) command:

```javascript
db.adminCommand( { replSetGetStatus: 1 } )
```

### Remove Invalid system.buckets Collections

When you upgrade to 9.0, if you have any `system.buckets` collections that are not time-series collections, you might need to [`drop`](https://www.mongodb.com/docs/manual/reference/method/db.collection.drop.md#mongodb-method-db.collection.drop) or [`rename`](https://www.mongodb.com/docs/manual/reference/method/db.collection.renamecollection.md#mongodb-method-db.collection.renameCollection) those collections before you upgrade, depending on your 8.0 patch release:

MongoDB 8.0.5 and later

You do not need to drop `system.buckets` collections that aren't time-series collections before you upgrade. However, you must drop or rename them after you complete your upgrade.

MongoDB 8.0.4 and earlier

You must drop or rename `system.buckets` collections that aren't time-series collections before you upgrade. All `system.buckets` collections must have valid [time series options](https://www.mongodb.com/docs/manual/reference/command/shardcollection.md#std-label-cmd-sharded-time-series-collection-options) configured before you upgrade to versions 8.0.0 - 8.0.4.

To determine whether you have `system.buckets` collections that are not time-series collections, use the [`db.getCollectionInfos()`](https://www.mongodb.com/docs/manual/reference/method/db.getcollectioninfos.md#mongodb-method-db.getCollectionInfos) method with a filter:

```javascript
db.getCollectionInfos(
   {
      $and: [
         { name: { $regex: /^system\.buckets/ } },
         { 'options.timeseries': { $exists: false } }
      ]
   }
)
```

## Download 8.0 Binaries

### Use a Package Manager

If you installed MongoDB from the MongoDB `apt`, `yum`, `dnf`, or `zypper` repositories, you should upgrade to 8.0 using your package manager.

Follow the appropriate [9.0 installation instructions](https://www.mongodb.com/docs/manual/installation.md#std-label-tutorial-installation) for your Linux system. This requires adding a repository for the new release, then performing the actual upgrade process.

### Manually

If you have not installed MongoDB using a package manager, you can manually download the MongoDB binaries from the [MongoDB Download Center](https://www.mongodb.com/try/download).

See [8.0 installation instructions](https://www.mongodb.com/docs/manual/installation.md#std-label-tutorial-installation) for more information.

## Upgrade Procedure

You can upgrade from MongoDB 7.0 to 8.0 using a "rolling" upgrade to minimize downtime by upgrading the members individually while the other members are available.

1. Shut down the replica set member.

   To shut down the [`mongod`](https://www.mongodb.com/docs/manual/reference/program/mongod.md#mongodb-binary-bin.mongod) process, use [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh) to connect to the replica set member and run the following command:

   ```javascript
   db.adminCommand( { shutdown: 1 } )
   ```

2. Upgrade secondary members of the replica set.

   Upgrade the [secondary](https://www.mongodb.com/docs/manual/core/replica-set-members.md#std-label-replica-set-secondary-members) members of the replica set one at a time:

   1. Replace the 7.0 binary with the 8.0 binary.

   2. Restart the member.

3. Step down the replica set primary.

   Connect [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh) to the primary and use [`rs.stepDown()`](https://www.mongodb.com/docs/manual/reference/method/rs.stepdown.md#mongodb-method-rs.stepDown) to step down the primary and force an election of a new primary.

4. Upgrade the primary.

   When [`rs.status()`](https://www.mongodb.com/docs/manual/reference/method/rs.status.md#mongodb-method-rs.status) shows that the primary has stepped down and another member has assumed `PRIMARY` state, upgrade the stepped-down primary:

   1. Shut down the stepped-down primary and replace the [`mongod`](https://www.mongodb.com/docs/manual/reference/program/mongod.md#mongodb-binary-bin.mongod) binary with the 8.0 binary.

   2. Restart the member.

5. Enable backwards-incompatible 8.0 features.

   At this point, you can run the 8.0 binaries without the 8.0 [features](https://www.mongodb.com/docs/manual/release-notes/9.0-compatibility.md#std-label-9.0-downgrade-incompatible) that are incompatible with 7.0.

   To enable these 8.0 features, set the feature compatibility version (`FCV`) to 8.0. You must also set `confirm` to 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`](https://www.mongodb.com/docs/manual/reference/command/setfeaturecompatibilityversion.md#mongodb-dbcommand-dbcmd.setFeatureCompatibilityVersion) command while an initial sync is in progress will cause the initial sync to restart.

   On the primary, run the [`setFeatureCompatibilityVersion`](https://www.mongodb.com/docs/manual/reference/command/setfeaturecompatibilityversion.md#mongodb-dbcommand-dbcmd.setFeatureCompatibilityVersion) command in the `admin` database:

   ```javascript
   db.adminCommand( { setFeatureCompatibilityVersion: "8.0",  confirm: true } )
   ```

   Setting [featureCompatibilityVersion (FCV) : "8.0"](https://www.mongodb.com/docs/manual/reference/command/setfeaturecompatibilityversion.md#std-label-set-fcv) implicitly performs a [`replSetReconfig`](https://www.mongodb.com/docs/manual/reference/command/replsetreconfig.md#mongodb-dbcommand-dbcmd.replSetReconfig) to add the [`term`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.term) field to the configuration document and blocks until the new configuration propagates to a majority of replica set members.

   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.

## Troubleshooting

If you experience startup issues after you upgrade, contact [MongoDB Support](https://support.mongodb.com/welcome) for assistance.

## Additional Upgrade Procedures

- To upgrade a standalone, see [Upgrade a Standalone to 8.0.](https://www.mongodb.com/docs/manual/release-notes/8.0-upgrade-standalone.md#std-label-8.0-upgrade-standalone)

- To upgrade a sharded cluster, see [Upgrade a Sharded Cluster to 8.0.](https://www.mongodb.com/docs/manual/release-notes/8.0-upgrade-sharded-cluster.md#std-label-8.0-upgrade-sharded-cluster)
