For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.

Upgrade to MongoDB Enterprise (Sharded Cluster)

MongoDB Enterprise provides various features not available in the MongoDB Community edition, such as:

The following steps outline the procedure to upgrade a sharded cluster from the MongoDB Community Edition to the MongoDB Enterprise Edition. For example, the steps can be used to upgrade MongoDB 7.0 Community to MongoDB 7.0 Enterprise.

Starting in MongoDB 8.0, you can use the directShardOperations role to perform maintenance operations that require you to execute commands directly against a shard.

Warning

Running commands using the directShardOperations role can cause your cluster to stop working correctly and may cause data corruption. Only use the directShardOperations role for maintenance purposes or under the guidance of MongoDB support. Stop using the directShardOperations role when you finish performing maintenance operations.

Warning

Do not use these instructions to upgrade to another release version.

For general guidance on MongoDB version numbering, release types, and upgrade paths, see MongoDB Versions and Upgrade Paths.

With Ops Manager, you can automatically upgrade from MongoDB Community Server to MongoDB Enterprise Server.

For more information, see Change MongoDB Version.

When updating the sharded clusters manually, you can perform a rolling upgrade on the shard replica sets and config servers to update each MongoDB Community Server to Enterprise edition with minimal downtime.

In a rolling upgrade, each secondary is taken down and upgraded. The Enterprise server rejoins the replica set as a secondary. When all secondaries are upgraded, you can step down the primary, forcing the replica set to elect one of the Enterprise servers as the new primary.

To minimize downtime, manually upgrade each from MongoDB Community Server to Enterprise Edition:

1

During an upgrade, the balancer should not attempt to redistribute data between the shards. To prevent the balancer from attempting to redistribute data, stop the balancer for the duration of the upgrade.

To stop the balancer, connect to mongos and run the sh.stopBalancer() method:

sh.stopBalancer()

If a balancing round is in progress, the operation waits for balancing to complete.

To confirm that the balancer is stopped, use the sh.getBalancerState() method:

sh.getBalancerState()
false

The command returns false when the balancer is stopped.

2

Perform a rolling upgrade of the config servers.

For the procedure, see Upgrade a Replica Set to MongoDB Enterprise.

3

Perform a rolling upgrade on each shard.

For the procedure, see Upgrade a Replica Set to MongoDB Enterprise.

4

Perform a rolling upgrade of the mongos instances from the Community installation to Enterprise.

  1. Connect to mongos and stop the router process:

    db.getSiblingDB("admin").shutdownServer()
  2. If you installed mongos with a package manager on Linux, you must remove the existing packages before you install the Enterprise mongos

    To remove the Community mongos:

    To remove the Community mongos from RHEL, CentOS, Alma Linux, Oracle, Rocky, and Amazon Linux, run the following command:

    sudo dnf remove mongodb-mongos
  3. Depending on your operating system, you can install the MongoDB Enterprise binaries by using a package manager or by downloading the binaries manually.

    If you have installed MongoDB Community using a package manager, follow the package manager instructions for your operating system:

  4. To start the router, run Enterprise mongos with the same configuration as you used for the Community mongos.

    For example:

    sudo mongos --config /etc/mongos.conf
5

To restart the balancer, connect to mongos and use the sh.startBalancer() method:

sh.startBalancer()

To confirm that the balancer is running, use the sh.getBalancerState() method:

sh.getBalancerState()
true

The command returns true when the balancer is running.

Important

Before using any Enterprise features, ensure that all members have been upgraded to Enterprise edition.