On this page本页内容
Warning
When upgrading a MongoDB 4.2-series deployment containing MongoDB 3.0 metadata to a 4.4-series deployment, you must upgrade to MongoDB 4.4.1 or later. You cannot successfully upgrade a deployment containing MongoDB 3.0 metadata to MongoDB 4.4.0 without serious risk of downtime.
For more information, see WT-6623.
Familiarize yourself with the content of this document, including thoroughly reviewing the prerequisites, prior to upgrading to MongoDB 4.4.
If you need guidance on upgrading to 4.4, MongoDB offers major version upgrade services to help ensure a smooth transition without interruption to your MongoDB application.
When upgrading, consider the following:
To upgrade an existing MongoDB deployment to 4.4, you must be running a 4.2-series release.
To upgrade from a version earlier than the 4.2-series, you must successively upgrade major releases until you have upgraded to 4.2-series. For example, if you are running a 4.0-series, you must upgrade first to 4.2 before you can upgrade to 4.4.
Before beginning your upgrade, see the Compatibility Changes in MongoDB 4.4 document to ensure that your applications and deployments are compatible with MongoDB 4.4. 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.
Once upgraded to 4.4, if you need to downgrade, we recommend downgrading to the latest patch release of 4.2.
Downgrade Floor
If you need to downgrade form version 4.4, downgrade to 4.2.6 or a later version. You cannot downgrade to 4.2.5 or an earlier version.
To upgrade a sharded cluster to 4.4, all members of the cluster must be at least version 4.2. The upgrade process checks all components of the cluster and will produce warnings if any component is running version earlier than 4.2.
Prior to upgrading a member of the sharded cluster, confirm that the member was cleanly shut down.
The 4.2 sharded cluster must have featureCompatibilityVersion
set to "4.2"
.
To ensure that all members of the sharded cluster have featureCompatibilityVersion
set to "4.2"
, connect to each shard replica set member and each config server replica set member and check the featureCompatibilityVersion
:
Tip
For a sharded cluster that has access control enabled, to run the following command against a shard replica set member, you must connect to the member as a shard local user.
All members should return a result that includes "featureCompatibilityVersion" : { "version" : "4.2" }
.
To set or update featureCompatibilityVersion
, run the following command on the mongos
:
For more information, see setFeatureCompatibilityVersion
.
For shards and config servers, ensure that no replica set member is in ROLLBACK
or RECOVERING
state.
config
Database¶Optional but Recommended. As a precaution, take a backup of the config
database before upgrading the sharded cluster.
If you installed MongoDB from the MongoDB apt
, yum
, dnf
, or zypper
repositories, you should upgrade to 4.4 using your package manager.
Follow the appropriate 4.4 installation instructions for your Linux system. This will involve adding a repository for the new release, then performing the actual upgrade process.
If you have not installed MongoDB using a package manager, you can manually download the MongoDB binaries from the MongoDB Download Center.
See 4.4 installation instructions for more information.
Connect a mongo
shell to a mongos
instance in the sharded cluster, and run sh.stopBalancer()
to disable the balancer:
Note
If a migration is in progress, the system will complete the in-progress migration before stopping the balancer. You can run sh.isBalancerRunning()
to check the balancer’s current state.
To verify that the balancer is disabled, run sh.getBalancerState()
, which returns false if the balancer is disabled:
For more information on disabling the balancer, see Disable the Balancer.
mongod
instance and replace the 4.2 binary with the 4.4 binary.--configsvr
, --replSet
, and --port
. Include any other options as used by the deployment.
If using a configuration file, update the file to specify sharding.clusterRole: configsvr
, replication.replSetName
, net.port
, and net.bindIp
, then start the 4.4 binary:
Include any other settings as appropriate for your deployment.
SECONDARY
state before upgrading the next secondary member. To check the member’s state, issue rs.status()
in the mongo
shell.
Repeat for each secondary member.
mongo
shell to the primary and use rs.stepDown()
to step down the primary and force an election of a new primary:
rs.status()
shows that the primary has stepped down and another member has assumed PRIMARY
state, shut down the stepped-down primary and replace the mongod
binary with the 4.4 binary.--configsvr
, --replSet
, --port
, and --bind_ip
options. Include any optional command line options used by the previous deployment:
If using a configuration file, update the file to specify sharding.clusterRole: configsvr
, replication.replSetName
, net.port
, and net.bindIp
, then start the 4.4 binary:
Include any other configuration as appropriate for your deployment.
Upgrade the shards one at a time.
For each shard replica set:
mongod
instance and replace the 4.2 binary with the 4.4 binary.--shardsvr
, --replSet
, --port
, and --bind_ip
options. Include any additional command line options as appropriate for your deployment:
If using a configuration file, update the file to include sharding.clusterRole: shardsvr
, replication.replSetName
, net.port
, and net.bindIp
, then start the 4.4 binary:
Include any other configuration as appropriate for your deployment.
SECONDARY
state before upgrading the next secondary member. To check the member’s state, you can issue rs.status()
in the mongo
shell.
Repeat for each secondary member.
Connect a mongo
shell to the primary and use rs.stepDown()
to step down the primary and force an election of a new primary:
rs.status()
shows that the primary has stepped down and another member has assumed PRIMARY
state, upgrade the stepped-down primary:
mongod
binary with the 4.4 binary.--shardsvr
, --replSet
, --port
, and --bind_ip
options. Include any additional command line options as appropriate for your deployment:
If using a configuration file, update the file to specify sharding.clusterRole: shardsvr
, replication.replSetName
, net.port
, and net.bindIp
, then start the 4.4 binary:
Include any other configuration as appropriate for your deployment.
mongos
instances.¶Replace each mongos
instance with the 4.4 binary and restart. Include any other configuration as appropriate for your deployment.
Note
The --bind_ip
option must be specified when the sharded cluster members are run on different hosts or if remote clients connect to the sharded cluster. For more information, see Localhost Binding Compatibility Changes.
Using a 4.4 mongo
shell, connect to a mongos
in the cluster and run sh.startBalancer()
to re-enable the balancer:
Starting in MongoDB 4.2, sh.startBalancer()
also enables auto-splitting for the sharded cluster.
If you do not wish to enable auto-splitting while the balancer is enabled, you must also run sh.disableAutoSplit()
.
For more information about re-enabling the balancer, see Enable the Balancer.
At this point, you can run the 4.4 binaries without the 4.4 features that are incompatible with 4.2.
To enable these 4.4 features, set the feature compatibility version (FCV
) to 4.4.
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.
On a mongos
instance, run the setFeatureCompatibilityVersion
command in the admin
database:
Setting featureCompatibilityVersion (fCV) : “4.4” implicitly performs a replSetReconfig
on each shard to add the term
field to the shard replica 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 mongos
as the operation is idempotent.
Note
While setFeatureCompatibilityVersion
is running on the sharded cluster, chunk migrations, splits, and merges can fail with ConflictingOperationInProgress
.
Any orphaned documents that exist on your shards will be cleaned up when you set the setFeatureCompatibilityVersion
to 4.4. The cleanup process:
Additional Consideration
Starting in MongoDB 4.0, the mongos
binary will crash when attempting to connect to mongod
instances whose feature compatibility version (fCV) is greater than that of the mongos
. For example, you cannot connect a MongoDB 4.2 version mongos
to a 4.4 sharded cluster with fCV set to 4.4. You can, however, connect a MongoDB 4.2 version mongos
to a 4.4 sharded cluster with fCV set to 4.2.