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
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Managed Service for MongoDB
  • Getting started
    • All guides
      • Managing shards
      • Selecting a different primary replica
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Enabling sharding
  • Listing shards in a cluster
  • Creating a shard
  • Deleting a shard
  1. Step-by-step guides
  2. Sharding and replication
  3. Managing shards

Managing shards MongoDB

Written by
Yandex Cloud
Updated at May 5, 2025
  • Enabling sharding
  • Listing shards in a cluster
  • Creating a shard
  • Deleting a shard

You can create a sharded cluster or enable sharding later. After that, you can add and configure shards.

Make sure your shards consist of at least three MONGOD hosts for higher availability. We do not recommend sharding small collections: query processing is faster with a standard replica cluster.

Alert

After cluster sharding is enabled:

  • There is no way to disable sharding. The cluster will always maintain a minimum number of MONGOS, MONGOCFG, or MONGOINFRA hosts depending on the sharding type.
  • To access databases, use only the MONGOS or MONGOINFRA hosts that route queries to shards. For this purpose, edit host addresses in your application code accordingly.

Enabling shardingEnabling sharding

The Managed Service for MongoDB interface lets you quickly create a MongoDB sharding infrastructure.

To learn how to directly shard your MongoDB database and collections, see Sharding collections.

To enable sharding, you need:

  • At least 3 MONGOINFRA hosts for standard sharding.
  • At least 2 MONGOS and 3 MONGOCFG hosts for advanced sharding.

Note

Sharding is not supported for hosts of b1.medium and b2.medium classes. If you do not see the Shards tab, upgrade the cluster host class to the supported value.

Management console
CLI
Terraform
REST API
gRPC API
  1. Go to the folder page and select Managed Service for MongoDB.

  2. Click the cluster name and open the Shards tab.

  3. Click Enable.

  4. Select a sharding type:

    • Standard: Based on MONGOINFRA hosts.

    • Advanced: Based on MONGOS and MONGOCFG hosts.

      For more information, see Sharding.

    Warning

    After you enable sharding, you can't change its type.

  5. Set the parameters of the hosts that will provide access to the sharded data.

  6. Click Enable sharding.

The cluster will start updating, with the requested hosts and first shard of the cluster created.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

  • To enable standard cluster sharding using MONGOINFRA hosts, run this command (the list of supported parameters in the example is not exhaustive):

    yc managed-mongodb cluster enable-sharding \
      --cluster-name=<cluster_name> \
      --host type=mongoinfra,`
        `zone-id=<availability_zone>,`
        `subnet-name=<subnet_name> \
      --host type=mongoinfra,`
        `zone-id=<availability_zone>,`
        `subnet-name=<subnet_name> \
      --host type=mongoinfra,`
        `zone-id=<availability_zone>,`
        `subnet-name=<subnet_name> \
      --mongoinfra resource-preset=<host_class>,`
        `disk-size=<storage_size_in_GB>,`
        `disk-type=<disk_type>
    

    Where:

    • --cluster-name: Cluster name you can get with a list of clusters in the folder.
    • --host: Host parameters:
      • type: Type (MONGOINFRA).
      • zone-id: Availability zone.
      • subnet-name: Subnet name.
    • --mongoinfra: MONGOINFRA host parameters:
      • resource-preset: Host class.
      • disk-size: Storage size in GB.
      • disk-type: Disk type.
  • To enable advanced cluster sharding using MONGOS and MONGOCFG hosts, run this command (the list of supported parameters in the example is not exhaustive):

    yc managed-mongodb cluster enable-sharding \
      --cluster-name=<cluster_name> \
      --host type=mongos,`
        `zone-id=<availability_zone>,`
        `subnet-name=<subnet_name> \
      --host type=mongos,`
        `zone-id=<availability_zone>,`
        `subnet-name=<subnet_name> \
      --mongos resource-preset=<host_class>,`
        `disk-size=<storage_size_in_GB>,`
        `disk-type=<disk_type> \
      --host type=mongocfg,`
        `zone-id=<availability_zone>,`
        `subnet-name=<subnet_name> \
      --host type=mongocfg,`
        `zone-id=<availability_zone>,`
        `subnet-name=<subnet_name> \
      --host type=mongocfg,`
        `zone-id=<availability_zone>,`
        `subnet-name=<subnet_name> \
      --mongocfg resource-preset=<host_class>,`
        `disk-size=<storage_size_in_GB>,`
        `disk-type=<disk_type>
    

    Where:

    • --cluster-name: Cluster name you can get with a list of clusters in the folder.
    • --host: Host parameters:
      • type: Type (MONGOS or MONGOCFG).
      • zone-id: Availability zone.
      • subnet-name: Subnet name.
    • --mongos: MONGOS host parameters:
      • resource-preset: Host class.
      • disk-size: Storage size in GB.
      • disk-type: Disk type.
    • --mongocfg: MONGOCFG host parameters:
      • resource-preset: Host class.
      • disk-size: Storage size in GB.
      • disk-type: Disk type.
  1. Make sure the provider version you are using is 0.90 or higher:

    terraform version
    

    Result example:

    Terraform v1.4.6
    on darwin_arm64
    + provider registry.terraform.io/yandex-cloud/yandex v0.91.0
    
    If the version is older

    Update the provider version:

    1. In the folder with the .tf configuration file, add the credentials to environment variables.

    2. In the same folder, initialize the provider with the updated version specified in the configuration file:

      terraform init -upgrade
      
    3. Check the provider version:

      terraform version
      
  2. Open the current Terraform configuration file with an infrastructure plan.

    For information on how to create this file, see Creating a cluster.

  3. Add additional resources to the configuration file.

    For standard sharding of the cluster using MONGOINFRA hosts
    resources_mongoinfra {
      resource_preset_id = "<host_class>"
      disk_type_id       = "<disk_type>"
      disk_size          = <storage_size_in_GB>
    }
    
    host {
      zone_id   = "<availability_zone>"
      subnet_id = "<subnet_ID>"
      type      = "mongoinfra"
    }
    
    host {
      zone_id   = "<availability_zone>"
      subnet_id = "<subnet_ID>"
      type      = "mongoinfra"
    }
    
    host {
      zone_id   = "<availability_zone>"
      subnet_id = "<subnet_ID>"
      type      = "mongoinfra"
    }
    
    For advanced sharding of the cluster using MONGOS and MONGOCFG hosts
    resources_mongos {
      resource_preset_id = "<host_class>"
      disk_type_id       = "<disk_type>"
      disk_size          = <storage_size_in_GB>
    }
    
    resources_mongocfg {
      resource_preset_id = "<host_class>"
      disk_type_id       = "<disk_type>"
      disk_size          = <storage_size_in_GB>
    }
    
    host {
      zone_id   = "<availability_zone>"
      subnet_id = "<subnet_ID>"
      type      = "mongos"
    }
    
    host {
      zone_id   = "<availability_zone>"
      subnet_id = "<subnet_ID>"
      type      = "mongos"
    }
    
    host {
      zone_id   = "<availability_zone>"
      subnet_id = "<subnet_ID>"
      type      = "mongocfg"
    }
    
    host {
      zone_id   = "<availability_zone>"
      subnet_id = "<subnet_ID>"
      type      = "mongocfg"
    }
    
    host {
      zone_id   = "<availability_zone>"
      subnet_id = "<subnet_ID>"
      type      = "mongocfg"
    }
    
  4. 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.

  5. 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.

  1. Get an IAM token for API authentication and put it into the environment variable:

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

    curl \
        --request POST \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --header "Content-Type: application/json" \
        --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>:enableSharding' \
        --data '{
                  "<MongoDB_host_type>": {
                    "resources": {
                      "resourcePresetId": "<host_class>",
                      "diskSize": "<storage_size_in_bytes>",
                      "diskTypeId": "<disk_type>"
                    }
                  },
                  "hostSpecs": [
                    {
                      "zoneId": "<availability_zone>",
                      "subnetId": "<subnet_ID>",
                      "assignPublicIp": <public_host_address:_true_or_false>,
                      "type": "<host_type>",
                      "shardName": "<shard_name>",
                      "hidden": <host_visibility:_true_or_false>,
                      "secondaryDelaySecs": "<lag_in_seconds>",
                      "priority": "<host_priority_for_assignment_as_master>",
                      "tags": "<host_labels>"
                    },
                    { <similar_configuration_for_host_2> },
                    { ... },
                    { <similar_configuration_for_host_N> }
                  ]
                }'
    

    Where:

    • MongoDB host type depends on the sharding type. Possible values: mongocfg, mongos, and mongoinfra.

    • hostSpecs is an array of new hosts. One array element contains settings for a single host. The number of hosts depends on the sharding type.

      • zoneId: Availability zone.
      • subnetId: Subnet ID.
      • assignPublicIp: Internet access to the host via a public IP address.
      • type: Host type: MONGOINFRA, MONGOS, or MONGOCFG.
      • shardName: Shard name.
      • hidden: The host will either be visible or hidden.
      • secondaryDelaySecs: Host's lag behind the master.
      • priority: Host priority for assignment as a master if the primary master fails.
      • tags: Host labels.

    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.

  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.EnableSharding call and send a request, e.g., via gRPCurl:

    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>",
              "<MongoDB_host_type>": {
                "resources": {
                  "resource_preset_id": "<host_class>",
                  "disk_size": "<storage_size_in_bytes>",
                  "disk_type_id": "<disk_type>"
                }
              },
              "host_specs": [
                {
                  "zone_id": "<availability_zone>",
                  "subnet_id": "<subnet_ID>",
                  "assign_public_ip": <public_host_address:_true_or_false>,
                  "type": "<host_type>",
                  "shard_name": "<shard_name>",
                  "hidden": <host_visibility:_true_or_false>,
                  "secondary_delay_secs": "<lag_in_seconds>",
                  "priority": "<host_priority_for_assignment_as_master>",
                  "tags": "<host_labels>"
                },
                { <similar_configuration_for_host_2> },
                { ... },
                { <similar_configuration_for_host_N> }
              ]
            }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.mongodb.v1.ClusterService.EnableSharding
    

    Where:

    • MongoDB host type depends on the sharding type. Possible values: mongocfg, mongos, and mongoinfra.

    • host_specs is an array of new hosts. One array element contains settings for a single host. The number of hosts depends on the sharding type.

      • zone_id: Availability zone.
      • subnet_id: Subnet ID.
      • assign_public_ip: Internet access to the host via a public IP address.
      • type: Host type: MONGOINFRA, MONGOS, or MONGOCFG.
      • shard_name: Shard name.
      • hidden: The host will either be visible or hidden.
      • secondary_delay_secs: Host's lag behind the master.
      • priority: Host priority for assignment as a master if the primary master fails.
      • tags: Host labels.

    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.

Listing shards in a clusterListing shards in a cluster

Management console
CLI
REST API
gRPC API
  1. Go to the folder page and select Managed Service for MongoDB.
  2. Click the cluster name and open the Shards tab.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To get a list of shards in a cluster, run the following command:

yc managed-mongodb shards list --cluster-name <cluster_name>

Result:

+------+
| NAME |
+------+
| rs01 |
| rs02 |
+------+

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

  1. Get an IAM token for API authentication and put it into the environment variable:

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

    curl \
        --request GET \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>/shards'
    

    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.

  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.ListShards call and send the following request, e.g., via gRPCurl:

    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>"
            }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.mongodb.v1.ClusterService.ListShards
    

    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.

Creating a shardCreating a shard

The number of shards in Managed Service for MongoDB clusters is limited by the CPU and RAM quotas available to DB clusters in your cloud. To check the resources currently in use, open the Quotas page and find Yandex Managed Service for MongoDB.

Management console
CLI
Terraform
REST API
gRPC API
  1. Go to the folder page and select Managed Service for MongoDB.
  2. Click the cluster name and open the Shards tab.
  3. Click Create shard.
  4. Enter a name for the shard and add the number of hosts you need.
  5. Click Create shard.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To create a shard, run the command below (not all the supported parameters are listed):

yc managed-mongodb shards add <new_shard_name> \
  --cluster-name=<cluster_name> \
  --host zone-id=<availability_zone>,`
    `subnet-name=<subnet_name>

Where:

  • --cluster-name: Cluster name you can get with a list of clusters in the folder.
  • --host: Host parameters:
    • zone-id: Availability zone.
    • subnet-name: Subnet name.
  1. Make sure the provider version you are using is 0.90 or higher:

    terraform version
    

    Result example:

    Terraform v1.4.6
    on darwin_arm64
    + provider registry.terraform.io/yandex-cloud/yandex v0.91.0
    
    If the version is older

    Update the provider version:

    1. In the folder with the .tf configuration file, add the credentials to environment variables.

    2. In the same folder, initialize the provider with the updated version specified in the configuration file:

      terraform init -upgrade
      
    3. Check the provider version:

      terraform version
      
  2. Open the current Terraform configuration file with an infrastructure plan.

    For information on how to create this file, see Creating a cluster.

  3. Add to the Managed Service for MongoDB cluster description the required number of host blocks with MONGOD in the type parameter and shard name in the shard_name parameter:

    resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
      ...
      host {
        zone_id    = "<availability_zone>"
        subnet_id  = "<subnet_ID>"
        type       = "mongod"
        shard_name = "<shard_name>"
      }
    }
    
  4. 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.

  5. 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.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Use the Cluster.AddShard method and make a request, e.g., via cURL:

    curl \
        --request POST \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --header "Content-Type: application/json" \
        --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>/shards' \
        --data '{
                  "shardName": "<shard_name>",
                  "hostSpecs": [
                    {
                      "zoneId": "<availability_zone>",
                      "subnetId": "<subnet_ID>",
                      "assignPublicIp": <public_host_address:_true_or_false>,
                      "type": "<host_type>",
                      "shardName": "<shard_name>",
                      "hidden": <host_visibility:_true_or_false>,
                      "secondaryDelaySecs": "<time_in_seconds>",
                      "priority": "<host_priority_for_assignment_as_master>",
                      "tags": "<labels>"
                    },
                    { <similar_configuration_for_host_2> },
                    { ... },
                    { <similar_configuration_for_host_N> }
                  ]
                }'
    
    

    Where:

    • shardName: Name of the shard you are creating.

    • hostSpecs: Host parameters:

      • zoneId: Availability zone.
      • subnetId: Subnet ID.
      • assignPublicIp: Internet access to the host via a public IP address.
      • type: Host type. Specify MONGOD.
      • shardName: Shard name.
      • hidden: The host will either be visible or hidden.
      • secondaryDelaySecs: Host's lag behind the master.
      • priority: Host priority for assignment as a master if the primary master fails.
      • tags: Host labels.

    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.

  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.AddShard call and make a request, e.g., via gRPCurl:

    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>",
              "shard_name": "<shard_name>",
              "host_specs": [
                {
                  "zone_id": "<availability_zone>",
                  "subnet_id": "<subnet_ID>",
                  "assign_public_ip": <public_host_address:_true_or_false>,
                  "type": "<host_type>",
                  "shard_name": "<shard_name>",
                  "hidden": <host_visibility:_true_or_false>,
                  "secondary_delay_secs": "<time_in_seconds>",
                  "priority": "<host_priority_for_assignment_as_master>",
                  "tags": "<labels>"
                },
                { <similar_configuration_for_host_2> },
                { ... },
                { <similar_configuration_for_host_N> }
              ]
            }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.redis.v1.ClusterService.AddShard    
    

    Where:

    • shard_name: Name of the shard you are creating.

    • host_specs: Host parameters:

      • zone_id: Availability zone.
      • subnet_id: Subnet ID.
      • assign_public_ip: Internet access to the host via a public IP address.
      • type: Host type. Specify MONGOD.
      • shard_name: Shard name.
      • hidden: The host will either be visible or hidden.
      • secondary_delay_secs: Host's lag behind the master.
      • priority: Host priority for assignment as a master if the primary master fails.
      • tags: Host labels.

    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.

Deleting a shardDeleting a shard

You can delete a shard from a MongoDB cluster if it is not the only shard there. To replace the only shard in a cluster, first create a new shard and then remove the old one.

Note

The removeShard operation will be called for the shard being deleted and will safely transfer data to the remaining shards.

Management console
CLI
Terraform
REST API
gRPC API
  1. Go to the folder page and select Managed Service for MongoDB.
  2. Click the cluster name and open the Shards tab.
  3. Click the icon in the shard row and select Delete.
  4. In the window that opens, click Remove.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To delete a shard from the cluster, run:

yc managed-mongodb shards delete <shard_name> \
  --cluster-name=<cluster_name>

You can request the shard name with the list of shards in the cluster and the cluster name, with the list of clusters in the folder.

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

    For information on how to create this file, see Creating a cluster.

  2. Delete all shard-related host blocks from the Managed Service for MongoDB cluster description.

  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. Type yes and press Enter.

    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.

  1. Get an IAM token for API authentication and put it into the environment variable:

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

    curl \
        --request DELETE \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>/shards/<shard_name>'
    

    You can request the cluster ID with the list of clusters in the folder and the shard name, with the list of shards in the cluster.

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

  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.DeleteShard call and send the following request, e.g., via gRPCurl:

    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>",
              "shard_name": "<shard_name>" 
            }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.mongodb.v1.ClusterService.DeleteShard
    

    You can request the cluster ID with the list of clusters in the folder and the shard name, with the list of shards in the cluster.

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

Was the article helpful?

Previous
Managing database users
Next
Selecting a different primary replica
Yandex project
© 2025 Yandex.Cloud LLC