sh.startBalancer()

On this page本页内容

Definition定义

sh.startBalancer(timeout, interval)

Changed in version 4.2.在版本4.2中更改

Starts the balancer in a sharded cluster. 在分片集群中启动平衡器。Starting in MongoDB 4.2, sh.startBalancer() also enables auto-splitting for the sharded cluster.从MongoDB 4.2开始,sh.startBalancer()还支持自动分割分片集群。

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

Parameter参数Type类型Description描述
timeoutinteger

Optional. 可选。Time limit for enabling the balancer.启用平衡器的时间限制。

Defaults to 60000 milliseconds.默认为60000毫秒。

Changed in version 3.4.在版本3.4中更改

If using the 3.4 mongo shell with earlier version sharded clusters, the parameter specifies the amount of time to wait for the balancing round to start.如果对早期版本的分片集群使用3.4 mongo shell,该参数指定等待平衡轮开始的时间。

intervalinteger

Optional. 可选。The frequency (in milliseconds) at which to check if a balancing round has started.检查平衡轮是否已开始的频率(毫秒)。

Changed in version 3.4.在版本3.4中更改

Only applicable when using version 3.4 mongo shell with earlier version sharded clusters.仅适用于将3.4版mongo shell与早期版本的分片集群配合使用。

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

Behavior行为

Starting in MongoDB 3.4, the mongo shell method sh.startBalancer() is a wrapper around the balancerStart command. 从MongoDB 3.4开始,mongo shell方法sh.startBalancer()balancerStart命令的包装器。As such, the method does not wait for balancing to start.因此,该方法不会等待平衡开始。

In earlier versions, the method waited for the balancing to start.在早期版本中,该方法等待平衡开始。

←  sh.splitFind()sh.status() →