---
title: Upgrading MongoDB
description: To upgrade PingIntelligence, you must upgrade MongoDB from version 4.2 to 4.4 before proceeding to upgrade MongoDB to version 5.0.
component: pingintelligence
version: 5.2
page_id: pingintelligence:installing_pingintelligence_for_apis:pingintelligence_upgrading_mongodb
canonical_url: https://docs.pingidentity.com/pingintelligence/5.2/installing_pingintelligence_for_apis/pingintelligence_upgrading_mongodb.html
revdate: May 6, 2024
section_ids:
  before-you-begin: Before you begin
  about-this-task: About this task
  steps: Steps
  next-steps: Next steps
---

# Upgrading MongoDB

To upgrade PingIntelligence, you must upgrade MongoDB from version 4.2 to 4.4 before proceeding to upgrade MongoDB to version 5.0.

## Before you begin

1. Upgrading MongoDB from version 4.2 to 5.0 is a multi-step process. Before performing any upgrades, it's crucial to back up your MongoDB data.

2. Test that the upgraded system is working correctly with MongoDB 4.4 before upgrading to MongoDB 5.0.

3. Stop all API Behavioral Security (ABS), API Publish, and Dashboard components.

4. Ensure all replica set members are running MongoDB version 4.2.

5. Ensure the 4.2 replica set has `featureCompatibilityVersion` set to `4.2`:

   1. Connect to each replica set member and check `featureCompatibilityVersion` using the following command:

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

   2. To set or update `featureCompatibilityVersion`, run the following command on the primary:

      ```
      db.adminCommand( { setFeatureCompatibilityVersion: "4.2" } )
      ```

6. Ensure that no replica set member is in `.mongodb.com/docs/v5.3/reference/replica-states///[ROLLBACK]` or `.mongodb.com/docs/v5.3/reference/replica-states///[RECOVERING]` state by running the `rs.status() command` command in the primary.

7. Prior to upgrading a member of the replica set, confirm that the member was cleanly shut down.

8. Make sure that the `abs_rs.js` file has actual MongoDB IPs (instead of `localhost/127.0.0.1`) for the replica set members.

## About this task

To upgrade MongoDB version 4.2 to 5.0:

## Steps

1. Upgrade secondary members of the replica set:

   1. Shutdown the secondary `mongo` instance.

   2. <https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.15.tgz>`mongo` build] and untar it.

   3. Replace the 4.2 binary with the 4.4 binary.

   4. Restart the member.

2. To step down the primary and force an election of a new primary, connect a `.mongodb.com/docs/v5.3/reference/program/mongod///[mongod]` shell to the primary and use `.mongodb.com/docs/v5.3/reference/method/rs.stepDown///[rs.stepDown()]`.

3. When `.mongodb.com/docs/v5.3/reference/method/rs.status///[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 `.mongodb.com/docs/v5.3/reference/program/mongod///[mongod]` binary with the 4.4 binary.

   2. Restart the member.

4. To enable backwards-incompatible 4.4 features, run the `setFeatureCompatibilityVersion` command on the primary in the admin database:

   ```
   db.adminCommand( { setFeatureCompatibilityVersion: "4.4" } )
   ```

5. Repeat the prerequisites and steps 1-4 to upgrade from 4.4.15 to 5.0.18.

## Next steps

Complete the steps in [Migrating MongoDB from RHEL 7.9 to 8](pingintelligence_migrating_mongodb.html).
