Docs HomeMongoDB Manual

sh.stopBalancer()

On this page本页内容

Definition定义

sh.stopBalancer(timeout, interval)

Changed in version 6.1.6.1版更改。

Disables the balancer in a sharded cluster.禁用分片集群中的平衡器。

Starting in MongoDB 6.1, automatic chunk splitting is not performed. 从MongoDB 6.1开始,不执行自动区块分割。This is because of balancing policy improvements. 这是因为平衡政策的改进。Auto-splitting commands still exist, but do not perform an operation. 自动拆分命令仍然存在,但不执行操作。For details, see Balancing Policy Changes.有关详细信息,请参阅平衡策略更改

In MongoDB versions earlier than 6.1, sh.stopBalancer() also disables auto-splitting for the sharded cluster.在6.1之前的MongoDB版本中,sh.stopBalancer()还禁用了分片集群的自动拆分。

Important

mongosh Method

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

For the database command, see the balancerStop command.

For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.有关MongoDB API驱动程序,请参阅特定语言的MongoDB驱动程序文档

For the legacy mongo shell documentation, refer to the documentation for the corresponding MongoDB Server release:对于遗留的mongoshell文档,请参阅相应MongoDB Server版本的文档:

mongo shell v4.4

The method can take the following options:该方法可以采用以下选项:

Parameter参数Type类型Description描述
timeoutintegerTime limit for disabling the balancer.禁用平衡器的时间限制。
Defaults to 60000 milliseconds. 默认值为60000毫秒。
intervalintegerThe interval (in milliseconds) at which to check if the balancing round has stopped.检查平衡循环是否已停止的间隔(以毫秒为单位)。

You can only run sh.stopBalancer() on a mongos instance. 您只能在mongos实例上运行sh.stopBalancer()sh.stopBalancer() errors if run on mongod instance.如果在mongod实例上运行,sh.stopBalancer()将出错。

The mongosh shell method is a wrapper around the balancerStop command.mongoshshell方法是balancerStop命令的包装器。

Behavior行为

If a balancing round is in progress, the operation waits for balancing to complete.如果正在进行一轮平衡,则操作将等待平衡完成。