Skip to main content
Very ImportantMongoDB backup must be taken before performing the operation:
This example was performed on Ubuntu 22.04.

MongoDB 4.4 to 5.0 Upgrade

1) Updating Secondary Nodes from MongoDB 4.4 to 5.0

First, all MongoDB secondary nodes are updated to version 5.0 one by one.
1

Stop MongoDB service

2

Add MongoDB 5.0 repository

3

Install MongoDB 5.0

When installing the update, you must answer the config file update question with N to preserve your existing configuration file.
Very ImportantDuring installation, the system asks whether to rewrite the config file. If the configuration file is accidentally overwritten here, it must be restored to the old setting.
1

Start MongoDB service

2

Check replica set status

Replica set status is checked by connecting to any node:

2) Stepping Down a Node in Primary Role to Secondary Role

Connect to the primary node and step down the primary node’s role to secondary to allow a new primary node to be selected.
1

Connect to Primary Node

2

Step down Primary Node to Secondary Node

3

Check new Primary Node

After waiting a bit, it is checked that one of the Secondary Nodes has become Primary Node:

3) Updating Node That Left Primary Role from MongoDB 4.4 to 5.0

1

Stop MongoDB service

2

Add MongoDB 5.0 repository

3

Install MongoDB 5.0

When installing the update, you must answer the config file update question with N to preserve your existing configuration file.
4

Start MongoDB service

5

Check replica set status

Replica set status is checked by connecting to any node:

4) MongoDB 5.0 Feature Compatibility Check

After all Nodes have transitioned to MongoDB 5.0, before transitioning to MongoDB 6.0, the feature compatibility setting is set to 5.0 (on Primary Node).
1

Connect to Primary Node

2

Check feature compatibility

If the feature compatibility appears as 4 in the output of the following command, it should be updated to 5:
3

Update feature compatibility

If the value is not 5.0, you can change it with the following command:

MongoDB 5.0 to 6.0 Upgrade

5) Updating Secondary Nodes from MongoDB 5.0 to 6.0

After ensuring all MongoDB replicas have transitioned to version 5.0, you can transition to version 6.0. First, start by updating all secondary nodes sequentially.
1

Stop MongoDB service

2

Add MongoDB 6.0 repository

3

Install MongoDB 6.0

4

Start MongoDB service

5

Check replica set status

Check replica set status by connecting to any node:

6) Stepping Down a Node in Primary Role to Secondary Role

1

Connect to Primary Node

2

Step down Primary Node to Secondary Node

3

Check new Primary Node

After waiting a bit, it is checked that one of the upgraded Secondary Nodes has become Primary:

7) Updating Node That Left Primary Role from MongoDB 5.0 to 6.0

1

Stop MongoDB service

2

Add MongoDB 6.0 repository

3

Install MongoDB 6.0

4

Start MongoDB service

5

Check replica set status

Check replica set status by connecting to any node:

8) MongoDB 6.0 Feature Compatibility Check

After all Nodes have transitioned to MongoDB 6.0, the feature compatibility setting is set to 6.0 (on Primary Node).
1

Connect to Primary Node

2

Check feature compatibility

If the feature compatibility appears as 5 in the output of the following command, it should be updated to 6:
3

Update feature compatibility

If the value is not 6.0, you can change it with the following command:

MongoDB 6.0 to 7.0 Upgrade

9) Updating Secondary Nodes from MongoDB 6.0 to 7.0

After ensuring all MongoDB replicas have transitioned to version 6.0, you can transition to version 7.0. First, start by updating all secondary nodes sequentially.
1

Stop MongoDB service

2

Add MongoDB 7.0 repository

3

Install MongoDB 7.0

4

Start MongoDB service

5

Check replica set status

Check replica set status by connecting to any node:

10) Stepping Down a Node in Primary Role to Secondary Role

1

Connect to Primary Node

2

Step down Primary Node to Secondary Node

3

Check new Primary Node

After waiting a bit, it is checked that one of the upgraded Secondary Nodes has become Primary:

11) Updating Node That Left Primary Role from MongoDB 6.0 to 7.0

1

Stop MongoDB service

2

Add MongoDB 7.0 repository

3

Install MongoDB 7.0

4

Start MongoDB service

5

Check replica set status

Check replica set status by connecting to any node:

12) MongoDB 7.0 Feature Compatibility Check

After all Nodes have transitioned to MongoDB 7.0, the feature compatibility setting is set to 7.0 (on Primary Node).
1

Connect to Primary Node

2

Check feature compatibility

If the feature compatibility appears as 6 in the output of the following command, it should be updated to 7:
3

Update feature compatibility

If the value is not 7.0, you can change it with the following command:

MongoDB 7.0 to 8.0 Upgrade

13) Updating Secondary Nodes from MongoDB 7.0 to 8.0

After ensuring all MongoDB replicas have transitioned to version 7.0, you can transition to version 8.0. First, start by updating all secondary nodes sequentially.
If you are upgrading on RHEL servers, since the package manager is dnf instead of apt, the upgrade commands change as follows:
1

Stop MongoDB service

2

Add MongoDB 8.0 repository

3

Install MongoDB 8.0

4

Start MongoDB service

5

Check replica set status

Check replica set status by connecting to any node:

14) Stepping Down a Node in Primary Role to Secondary Role

1

Connect to Primary Node

2

Step down Primary Node to Secondary Node

3

Check new Primary Node

After waiting a bit, it is checked that one of the upgraded Secondary Nodes has become Primary:

15) Updating Node That Left Primary Role from MongoDB 7.0 to 8.0

1

Stop MongoDB service

2

Add MongoDB 8.0 repository

3

Install MongoDB 8.0

4

Start MongoDB service

5

Check replica set status

Check replica set status by connecting to any node:

16) MongoDB 8.0 Feature Compatibility Check

After all Nodes have transitioned to MongoDB 8.0, the feature compatibility setting is set to 8.0 (on Primary Node).
1

Connect to Primary Node

2

Check feature compatibility

If the feature compatibility appears as 7 in the output of the following command, it should be updated to 8:
3

Update feature compatibility

If the value is not 8.0, you can change it with the following command: