Sharding Methods分片方法

Note注意

For details on specific methods, including syntax and examples, click on the specific method to go to its reference page.有关特定方法的详细信息,包括语法和示例,请单击特定方法以转到其参考页面。

Name名称Description描述
sh.abortReshardCollection()

Aborts a resharding operation.中止重新分片操作

New in version 5.0.在版本5.0中新增

sh.addShard()Adds a shard to a sharded cluster.分片添加到分片群集。
sh.addShardTag()In MongoDB 3.4, this method aliases to sh.addShardToZone().在MongoDB 3.4中,该方法别名为sh.addShardToZone()
sh.addShardToZone()Associates a shard to a zone. 将分片关联到区域。Supports configuring zones in sharded clusters.支持在分片集群中配置区域
sh.addTagRange()In MongoDB 3.4, this method aliases to sh.updateZoneKeyRange().在MongoDB 3.4中,该方法别名为sh.updateZoneKeyRange()
sh.balancerCollectionStatus()

Returns information on whether the chunks of a sharded collection are balanced.返回分片集合的块是否平衡的信息。

New in version 4.4.在版本4.4中新增

sh.commitReshardCollection()

Forces a resharding operation to block writes and complete.强制重新分片操作阻止写入并完成。

New in version 5.0.在版本5.0中新增

sh.disableBalancing()Disable balancing on a single collection in a sharded database. 在分片数据库中的单个集合上禁用平衡。Does not affect balancing of other collections in a sharded cluster.不影响分片集群中其他集合的平衡。
sh.enableBalancing()Activates the sharded collection balancer process if previously disabled using sh.disableBalancing().如果之前使用sh.disableBalancing()禁用,则激活分片集合平衡器进程。
sh.disableAutoSplit()Disables auto-splitting for the sharded cluster.禁用分片群集的自动拆分。
sh.enableAutoSplit()Enables auto-splitting for the sharded cluster.启用分片群集的自动拆分。
sh.enableSharding()Enables sharding on a specific database.在特定数据库上启用分片。
sh.getBalancerHost()Deprecated since MongoDB 3.4自MongoDB 3.4以来已弃用
sh.getBalancerState()Returns a boolean to report if the balancer is currently enabled.返回一个布尔值,以报告当前是否启用了平衡器
sh.removeTagRange()In MongoDB 3.4, this method aliases to sh.removeRangeFromZone().在MongoDB 3.4中,该方法别名为sh.removeRangeFromZone()
sh.removeRangeFromZone()Removes an association between a range of shard keys and a zone. 删除一系列分片键和区域之间的关联。Supports configuring zones in sharded clusters.支持在分片集群中配置区域
sh.help()Returns help text for the sh methods.返回sh方法的帮助文本。
sh.isBalancerRunning()Returns a document describing the status of the balancer.返回描述平衡器状态的文档。
sh.moveChunk()Migrates a chunk in a sharded cluster.迁移分片集群中的
sh.removeShardTag()In MongoDB 3.4, this method aliases to sh.removeShardFromZone().在MongoDB 3.4中,该方法别名为sh.removeShardFromZone()
sh.removeShardFromZone()Removes the association between a shard and a zone. 删除分片和分区之间的关联。Use to manage zone sharding.用于管理区域分片
sh.reshardCollection()

Initiates a resharding operation to change the shard key for a collection, changing the distribution of your data.启动重新分片操作以更改集合的分片键,从而更改数据的分布。

New in version 5.0.在版本5.0中新增

sh.setBalancerState()Enables or disables the balancer which migrates chunks between shards.启用或禁用在分片之间迁移平衡器
sh.shardCollection()Enables sharding for a collection.为集合启用分片。
sh.splitAt()Divides an existing chunk into two chunks using a specific value of the shard key as the dividing point.使用分片键的特定值作为分割点,将现有分割为两个块。
sh.splitFind()Divides an existing chunk that contains a document matching a query into two approximately equal chunks.将包含与查询匹配的文档的现有划分为两个近似相等的块。
sh.startBalancer()Enables the balancer and waits for balancing to start.启用平衡器并等待平衡开始。
sh.status()Reports on the status of a sharded cluster, as db.printShardingStatus().报告分片集群的状态,如db.printShardingStatus()
sh.stopBalancer()Disables the balancer and waits for any in progress balancing rounds to complete.禁用平衡器并等待任何正在进行的平衡循环完成。
sh.waitForBalancer()Internal. 内部的。Waits for the balancer state to change.等待平衡器状态改变。
sh.waitForBalancerOff()Internal. 内部的。Waits until the balancer stops running.等待直到平衡器停止运行。
sh.waitForPingChange()Internal. 内部的。Waits for a change in ping state from one of the mongos in the sharded cluster.等待分片集群中某个mongos的ping状态发生变化。
sh.updateZoneKeyRange()Associates a range of shard keys to a zone. 将一系列分片键关联到一个区域。Supports configuring zones in sharded clusters.支持在分片集群中配置区域
convertShardKeyToHashed()Returns the hashed value for the input.返回输入的哈希值。
←  rs.syncFrom()sh.abortReshardCollection() →