Docs Menu

sh.setBalancerState()

sh.setBalancerState(state)

Enables or disables the バランサー.

MongoDB 6.0.3以降、 自動チャンク分割は実行されません。 これはバランシング ポリシーの改善によるものです。 自動分割コマンドは引き続き存在しますが、操作は実行されません。

In MongoDB versions earlier than 6.0.3, sh.setBalancerState() also enables auto-splitting if enabling the balancer and disables auto-splitting if disabling the balancer.

使用 sh.getBalancerState() to determine if the balancer is currently enabled or disabled and sh.isBalancerRunning() to check its current state.

重要

mongosh メソッド

このページでは、mongosh メソッドについて記載しています。ただし、データベースコマンドや Node.js などの言語固有のドライバーのドキュメントには該当しません

For the database command, see the balancerStart and balancerStop commands.

MongoDB API ドライバーについては、各言語の MongoDB ドライバー ドキュメントを参照してください。

重要

インスタンスではのみsh.setBalancerState() mongosを実行できます。sh.setBalancerState()mongod{ インスタンスで実行すると エラーが発生します。

sh.setBalancerState()メソッドには次のパラメーターがあります。

Parameter
タイプ
説明

state

ブール値

Set this to true to enable the balancer and false to disable it.

バランサーを長期間無効のままにすると、シャードのバランスが取れず、クラスターのパフォーマンスが低下する可能性があります。 必要な場合のみバランサーを無効にし、メンテナンスが完了した後にバランサーを再度有効にするようにします。

このメソッドは、次の環境でホストされている配置で使用できます。

  • MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです

重要

このコマンドは、M0 、M2 、M5 、および Flex クラスターではサポートされていません。詳細については、「 サポートされていないコマンド 」を参照してください。

  • MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン

  • MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン