Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for MongoDB
  • Getting started
    • All guides
      • Information about existing clusters
      • Creating a cluster
      • Updating cluster settings
      • MongoDB version upgrade
      • Stopping and starting a cluster
      • Managing cluster hosts
      • Migrating hosts to a different availability zone
      • Managing backups
      • Deleting a cluster
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Before a version upgrade
  • Upgrading a cluster
  • Examples
  1. Step-by-step guides
  2. Clusters
  3. MongoDB version upgrade

MongoDB version upgrade

Written by
Yandex Cloud
Improved by
amatol
Updated at May 5, 2025
  • Before a version upgrade
  • Upgrading a cluster
  • Examples

You can only upgrade your Managed Service for MongoDB cluster to a version that immediately follows the current one, such as 4.2 to 4.4. Upgrades to higher versions are performed in steps. For example, for MongoDB, the upgrade sequence from version 4.2 to 6.0 is: 4.2 → 4.4 → 5.0 → 6.0.

Alert

After upgrading, you cannot roll a cluster back to the previous version.

Before a version upgradeBefore a version upgrade

Make sure this does not affect your applications:

  1. See the MongoDB changelog to check how updates might affect your applications.
  2. Try a version upgrade on a test cluster. You can deploy it from a backup of the main cluster.
  3. Create a backup of the main cluster directly before the version upgrade.

Upgrading a clusterUpgrading a cluster

Management console
CLI
Terraform
REST API
gRPC API
  1. Go to the folder page and select Managed Service for MongoDB.
  2. Select the cluster from the list and click Edit.
  3. In the Version field, select a new version number.
  4. Click Save changes.

As soon as you run the upgrade, the cluster status will change to UPDATING. Wait for the operation to complete and then check the cluster version.

  1. Get a list of your MongoDB clusters using this command:

    yc managed-mongodb cluster list
    
  2. Get information about the cluster you need and check the MongoDB version in the config.version parameter:

    yc managed-mongodb cluster get <cluster_name_or_ID>
    
  3. Run the MongoDB upgrade:

    yc managed-mongodb cluster update <cluster_name_or_ID> \
       --mongodb-version=<new_version_number>
    

    As soon as you run the upgrade, the cluster status will change to UPDATING. Wait for the operation to complete and then check the cluster version.

  4. After the upgrade, all MongoDB features that are not backward-compatible with the previous version will be disabled. To remove this restriction, run this command:

    yc managed-mongodb cluster update <cluster_name_or_ID> \
       --feature-compatibility-version=<new_version_number>
    

    Learn more about backward compatibility in the MongoDB documentation.

  1. Open the current Terraform configuration file with an infrastructure plan.

    For more information about creating this file, see Creating clusters.

  2. To the Managed Service for MongoDB cluster description, add the version field or change its value if it is already there:

    resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
      ...
      cluster_config {
        version = "<MongoDB_version>"
      }
    }
    
  3. Make sure the settings are correct.

    1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  4. Confirm updating the resources.

    1. Run this command to view the planned changes:

      terraform plan
      

      If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

For more information, see the Terraform provider documentation.

Timeouts

The Terraform provider sets the following timeouts for Managed Service for MongoDB cluster operations:

  • Creating a cluster, including by restoring one from a backup: 30 minutes.
  • Editing a cluster: 60 minutes.

Operations exceeding the set timeout are interrupted.

How do I change these limits?

Add the timeouts block to the cluster description, for example:

resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
  ...
  timeouts {
    create = "1h30m" # An hour and a half
    update = "2h"    # Two hours
  }
}
  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Use the Cluster.Update method and send the following request, e.g., via cURL:

    Warning

    The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask parameter as a single comma-separated string.

    curl \
       --request PATCH \
       --header "Authorization: Bearer $IAM_TOKEN" \
       --header "Content-Type: application/json" \
       --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>' \
       --data '{
                "updateMask": "configSpec.version",
                "configSpec": {
                  "version": "<new_MongoDB_version>"
                }
              }'
    

    Where:

    • updateMask: List of parameters to update as a single string, separated by commas.

      In this case, one parameter is provided.

    • configSpec.version: New MongoDB version.

    You can request the cluster ID with the list of clusters in the folder.

  3. View the server response to make sure the request was successful.

  4. After the upgrade, all MongoDB features that are not backward-compatible with the previous version will be disabled. To remove this restriction, send one more request and provide the new MongoDB version number in the configSpec.featureCompatibilityVersion property.

    curl \
       --request PATCH \
       --header "Authorization: Bearer $IAM_TOKEN" \
       --header "Content-Type: application/json" \
       --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>' \
       --data '{
                "updateMask": "configSpec.featureCompatibilityVersion",
                "configSpec": {
                  "featureCompatibilityVersion": "<new_MongoDB_version>"
                }
              }'
    
  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Clone the cloudapi repository:

    cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
    

    Below, we assume the repository contents are stored in the ~/cloudapi/ directory.

  3. Use the ClusterService.Update call and send the following request, e.g., via gRPCurl:

    Warning

    The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the update_mask parameter as an array of paths[] strings.

    Format for listing settings
    "update_mask": {
        "paths": [
            "<setting_1>",
            "<setting_2>",
            ...
            "<setting_N>"
        ]
    }
    
    grpcurl \
        -format json \
        -import-path ~/cloudapi/ \
        -import-path ~/cloudapi/third_party/googleapis/ \
        -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d '{
              "cluster_id": "<cluster_ID>",
              "update_mask": {
                "paths": [ 
                  "config_spec.version"
                ]
              },  
              "config_spec": {
                "version": "<MongoDB_version>"
              }
           }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.mongodb.v1.ClusterService.Update
    

    Where:

    • update_mask: List of parameters to update as an array of paths[] strings.

      In this case, one parameter is provided.

    • version: New MongoDB version.

    You can request the cluster ID with the list of clusters in the folder.

  4. View the server response to make sure the request was successful.

  5. After the upgrade, all MongoDB features that are not backward-compatible with the previous version will be disabled. To remove this restriction, send one more request and provide the new MongoDB version number in the config_spec.feature_compatibility_version property.

    grpcurl \
        -format json \
        -import-path ~/cloudapi/ \
        -import-path ~/cloudapi/third_party/googleapis/ \
        -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d '{
              "cluster_id": "<cluster_ID>",
              "update_mask": {
                "paths": [ 
                  "config_spec.feature_compatibility_version"
                ]
              },  
              "config_spec": {
                "feature_compatibility_version": "<new_MongoDB_version>"
              }
           }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.mongodb.v1.ClusterService.Update
    

ExamplesExamples

Let's assume that you need to upgrade your cluster from version 5.0 to version 6.0.

CLI
  1. To find out the cluster ID, get a list of all clusters in the folder:

    yc managed-mongodb cluster list
    

    Result:

    +----------------------+---------------+---------------------+--------+---------+
    |          ID          |     NAME      |     CREATED AT      | HEALTH | STATUS  |
    +----------------------+---------------+---------------------+--------+---------+
    | c9q8p8j2gaih******** |   mongodb406  | 2019-04-23 12:44:17 | ALIVE  | RUNNING |
    +----------------------+---------------+---------------------+--------+---------+
    
  2. To get information about the c9qut3k64b2o******** cluster, run the following command:

    yc managed-mongodb cluster get c9qut3k64b2o********
    

    Result:

    id: c9qut3k64b2o********
    folder_id: b1g0itj57rbj********
    created_at: "2019-07-16T09:43:50.393231Z"
    name: mongodb406
    environment: PRODUCTION
    monitoring:
    - name: Console
      description: Console charts
      link: https://console.yandex.cloud/folders/b1g0itj57rbj********/managed-mongodb/cluster/c9qut3k64b2o********?section=monitoring
    config:
      version: "5.0"
      feature_compatibility_version: "5.0"
      ...
    
  3. To upgrade the c9qutgkd4b2o******** cluster to version 6.0, run this command:

    yc managed-mongodb cluster update c9qutgkd4b2o******** \
        --mongodb-version=6.0
    
  4. To enable all 6.0 features in the c9qutgkd4b2o******** cluster, run this command:

    yc managed-mongodb cluster update c9qutgkd4b2o******** \
        --feature-compatibility-version=6.0
    

Was the article helpful?

Previous
Updating cluster settings
Next
Stopping and starting a cluster
© 2025 Direct Cursus Technology L.L.C.