Release Notes
Announcements
Dimension | Shard Removal |
Billing Impact | Yearly/monthly subscription: The remaining balance of the original specifications and the price of the new specifications will be calculated and the difference will be refunded. At the next renewal cycle, charges will be based on the new specifications. Pay-as-you-go: Charges for the original specifications will be settled, and billing restarts based on the new specifications. For the detailed billing information, see Configuration Adjustment Billing. |
Version Requirement | General Edition: TencentDB for MongoDB 4.0 and later. Cloud Disk Edition: Shard removal is not supported. |
Service Impact | During the operation, no service interruption will occur. Database read and write operations are normal and both automatic and manual backups are supported. During the operation, you are strictly prohibited from performing any operations that may interfere with data migration, including but not limited to: Data rollback and instance termination Configuration adjustment and primary-secondary switch Connection address modification Operations on the shards to be removed |
Limits and Constraints | Removal order: To-be-removed shards are selected by creation time in descending order. Space requirement: After removal, the total storage space of the remaining shards must be greater than or equal to 120% of the used space of the cluster. Otherwise, removal is not allowed. Removal quantity: The number of shards to be removed each time cannot exceed half of the original shard quantity of the cluster. After removal, the number of shards must be greater than or equal to 2. Note: Due to kernel limitations, you can only remove one shard at a time in TencentDB for MongoDB 4.0. Balancer requirement: Before removal, enable the balancer and set the balancing window to control the impact of data migration on services. Time consumption: Shard removal will trigger data redistribution. This process may be slow, depending on the data volume, balancer settings, and other factors. |
No. | Check Item | Check Criteria | Specific Instruction and Operational Guideline |
1 | Instance status | The instance status is Running. | On the Instance List page, check that the target instance is running normally. |
2 | Shard quantity | Before removal, the shard quantity must be greater than 2. | This is a prerequisite. If the current number of shards equals 2, removal cannot be performed. Removing shards would result in fewer than 2 shards, which does not meet cluster architecture requirements. |
3 | Instance expiration time | The expiration time of a yearly/monthly subscription instance must be greater than or equal to 14 days. | In the Configuration Information section on the Instance Details page, view Expiration Time to ensure that the instance has sufficient remaining service time. |
4 | Storage space after removal | Total storage space of the remaining shards > Current used space of the cluster x 120% | 1. In the Specifications section on the Instance Details page, view the total storage space and used space. 2. Calculate the total storage space of the remaining shards, as shown in the example below. Current total space: 150 GB (3 shards x 50 GB) Shards to be removed: 1 shard Space after removal: 100 GB Currently used: 1.5 GB Minimum required space: 1.5 GB x 120% = 1.8 GB Verification: Because 100 GB is greater than 1.8 GB, the check passed. |
5 | Balancer settings | Ensure that the balancer is enabled. It is recommended to set the balancing window. | 1. On the Parameter Settings page in the console, set the openBalance.window parameter to true to enable the balancer. 2. Set off-peak hours as the balancing window by configuring the balance.window parameter to minimize the impact of data migration on services. For specific operations, see Database Parameter Adjustment. |
6 | Primary shard check | Confirm that the shard to be removed is not the primary shard of any unsharded collection. | 1. Connect to the instance using the MongoDB Shell, query the config database by executing getSiblingDB("config").databases.find(), and identify the databases where a to-be-removed shard serves as the primary shard. Note: The shard name format is cmgo-xxxxxxxx_n. xxxxxxxx is the unique instance identifier (8 characters) and n is the shard sequence number starting from 0. For example, a 5-shard instance would have shard names ranging from cmgo-xxxxxxxx_0 to cmgo-xxxxxxxx_4. If you need to remove the last shard, you should specify cmgo-xxxxxxxx_4.
2. For each identified database, use the getCollectionNames() method to obtain a complete list of all collections.
3. Check the sharding status of each collection by executing db.collection.stats().sharded. If the return value is false (indicating unsharded), you must execute the movePrimary command to move the primary shard of the database containing this collection to another shard. For details, see movePrimary (database command). Note: In TencentDB for MongoDB 4.0 and 4.2, after movePrimary is executed, it is necessary to refresh the routing information. Otherwise, read and write operations may be blocked. The refresh method is as follows: Version 4.0: After executing movePrimary, restart all mongos nodes or execute the flushRouterConfig command on all mongos nodes. Version 4.2: After executing movePrimary, restart all mongos and mongod nodes or execute the flushRouterConfig command on all mongos and mongod nodes.
See Appendix: Example of Verifying That the Shard to Be Removed Is Not the Primary Shard of Any Unsharded Collection for operational examples. |


Parameter Category | Parameter | Example | Description |
Basic Instance Information | Instance Name | test-4dot2-XXX | Name of the instance for which the shard quantity is to be reduced. |
| Expiration Time | 2025-04-24 19:23:43 | Service expiration time of a yearly/monthly subscription instance. |
| Instance Architecture | A sharded cluster instance that has 3 shards, each with 4 nodes, among which there is 1 read-only node | Cluster architecture of the instance: sharded cluster instance. Shard quantity: shard quantity before removal. Nodes per shard: number of nodes per shard and number of read-only nodes. |
| Node Specification | 2 cores, 4 GB memory, 250 GB storage, and 10 nodes in total | Single shard node specification: including CPU cores, memory, and storage capacity. Total number of cluster nodes: total number of nodes in the instance before removal (Number of shards x Nodes per shard = Total number of cluster nodes). |
Configuration Downgrade | Number of Shards to Be Deleted | 2 | Specify the number of shards to be removed for the instance. |
| | | After specifying the number of shards to be removed, click Check Shards to Be Removed to check whether the conditions for removing shards are met. Check the number of remaining shards: Ensure that the number of remaining shards is not less than 2 after removal. Check the storage space: Ensure that the total storage space of the remaining shards after removal is greater than 120% of the currently used space in the cluster. Check the primary shard information: Check whether the shards to be removed contain any primary shards of databases. If yes, you must manually move them to other shards before proceeding. |
Cost Information | Fees | 0.92 USD/hour | Pay-as-you-go: The hourly billing rate after shard removal for the instance will be displayed. Yearly/monthly subscription: The refund amount after the specifications are downgraded will be displayed. |
API | Description |
Adjusts the cloud database instance configurations | |
Queries the sales specifications of cloud databases |
getSiblingDB("config").databases.find(), and identify the databases whose primary shard is the shard to be removed. The following example shows how to query the databases where shard cmgo-xxxxxxxx_3 serves as the primary shard.mongos> db.getSiblingDB("config").databases.find({primary: "cmgo-xxxxxxxx_3"}){ "_id" : "bulk_db_db_3", "primary" : "cmgo-xxxxxxxx_3", "partitioned" : false, "version" : { "uuid" : UUID("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"), "timestamp" : Timestamp(1762855003, 5), "lastMod" : 1 } }{ "_id" : "bulk_db_db_4", "primary" : "cmgo-xxxxxxxx_3", "partitioned" : false, "version" : { "uuid" : UUID("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), "timestamp" : Timestamp(1762855035, 2), "lastMod" : 1 } }{ "_id" : "bulk_db_db_10", "primary" : "cmgo-xxxxxxxx_3", "partitioned" : false, "version" : { "uuid" : UUID("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), "timestamp" : Timestamp(1762855333, 3), "lastMod" : 1 } }{ "_id" : "bulk_db_db_14", "primary" : "cmgo-xxxxxxxx_3", "partitioned" : false, "version" : { "uuid" : UUID("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), "timestamp" : Timestamp(1762855462, 30), "lastMod" : 1 } }
mongos> db.getSiblingDB("bulk_db_db_77").getCollectionNames()["collection_1","collection_10","collection_11","collection_12","collection_13","collection_14","collection_15","collection_16","collection_17","collection_18","collection_19","collection_2","collection_20","collection_3","collection_4","collection_5","collection_6","collection_7","collection_8","collection_9"]
mongos> db.getSiblingDB("bulk_db_db_77").collection1.stats(){"sharded" : false,"primary" : "cmgo-xxxxxxxx_3","ns" : "bulk_db_db_77.collection1","count" : 0,"size" : 0,"storageSize" : 0,"totalIndexSize" : 0,"totalSize" : 0,"indexSizes" : {},"avgObjSize" : 0,"maxSize" : NumberLong(0),"nindexes" : 0,"scaleFactor" : 1,"nchunks" : 1,"shards" : {"cmgo-xxxxxxxx_3" : {"ns" : "bulk_db_db_77.collection1","size" : 0,"count" : 0,"numOrphanDocs" : 0,"storageSize" : 0,"totalSize" : 0,"nindexes" : 0,"totalIndexSize" : 0,"indexDetails" : {},"indexSizes" : {},"scaleFactor" : 1,"ok" : 1,"$clusterTime" : {"clusterTime" : Timestamp(1763094536, 1),"signature" : {"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),"keyId" : NumberLong(0)}},"$configTime" : Timestamp(1763094535, 2),"$topologyTime" : Timestamp(1762853939, 5),"operationTime" : Timestamp(1763094536, 1)}},"ok" : 1,"$clusterTime" : {"clusterTime" : Timestamp(1763094536, 1),"signature" : {"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),"keyId" : NumberLong(0)}},"operationTime" : Timestamp(1763094536, 1)}mongos> db.getSiblingDB("bulk_db_db_77").collection1.stats().shardedfalse
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback