定义
sh.commitReshardCollection(namespace)版本 5.0 中的新增功能。
在重新分片操作期间,MongoDB 不会阻止写入,直到完成重新分片操作的估计持续时间低于两秒。
If the current estimate is above two seconds but the time frame is acceptable to you, you can finish resharding faster. The
sh.commitReshardCollection()method blocks writes early and forces the resharding operation to complete.重要
mongosh 方法
This page documents a
mongoshmethod. This is not the documentation for database commands or language-specific drivers, such as Node.js.有关数据库命令,请参阅
commitReshardCollection命令。如需了解 MongoDB API 驱动程序,请参阅特定语言的 MongoDB 驱动程序文档。
兼容性
此方法可用于以下环境中托管的部署:
- MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
重要
M0 和 Flex 集群不支持此命令。有关更多信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
The sh.commitReshardCollection() method has the following syntax:
sh.commitReshardCollection( <namespace> )
Parameter
The sh.commitReshardCollection() method takes the following parameter:
Parameter | 类型 | 说明 |
|---|---|---|
字符串 | 要分片的集合名称,格式为 |
例子
提交重新分片操作
以下命令强制sales.orders上的重新分片操作以阻止写入并完成:
sh.commitReshardCollection("sales.orders")
提示