定義
moveRangeバージョン6.0の新機能。
Moves ranges between shards. Run the
moveRangecommand with amongosinstance while using the admin database.Tip
In
mongosh, this command can also be run through thesh.moveRange()helper method.Helper methods are convenient for
mongoshusers, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
注意
This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
構文
このコマンドの構文は、次のとおりです。
db.adminCommand( { moveRange: <namespace>, toShard: <ID of the recipient shard>, min: <min key of the range to move>, // conditional max: <max key of the range to move>, // conditional forceJumbo: <bool>, // optional writeConcern: <write concern>, // optional secondaryThrottle: <bool> // optional } )
コマンドフィールド
このコマンドは、次のフィールドを使用します。
フィールド | タイプ | 説明 |
|---|---|---|
| string | 受信者シャードの ID。 |
| キー | 移動する範囲の最小キー。
|
| キー | 移動する範囲の最大キー。
|
ブール値 | 任意。 コマンドが 移行するには大きすぎる範囲を移動できるかどうかを決定するフラグです。 その範囲にはジャンボ というラベルが付いている場合と付いていない場合があります。
デフォルトは 警告:
このオプションを指定すると、シャードは、設定された チャンク サイズ よりも大きい場合でも、チャンクを移行します。 コレクションは、 移行中は書き込みができなくなります。 この長いブロッキング期間なしでこれらの大きなチャンクを移行するには、代わりに「サイズ制限を超えるバランス範囲」を参照してください。 | |
| ドキュメント | |
| ブール値 | 任意。
詳細については、「セカンダリ スロットル 」を参照してください。 |
範囲移行セクションでは、範囲が MongoDB 上のシャード間で範囲がどのように移動されるかについて説明します。
Considerations
Only use the moveRange in scenarios like:
データの初期取り込み
大規模な一括インポート操作
ほとんどの場合、バランサーがシャーディングされたクラスターに範囲を作成し、範囲を作成できるようにします。
例
次の例では、次の内容を含む コレクションを使用します。
シャードキー
x128MB の チャンク サイズ に設定
境界のあるチャンク:
[x: 0, x: 100)
と の両方を指定minmax
次の表は、 minとmaxをさまざまな値に設定した結果を示しています。
min | max | 結果 |
|---|---|---|
|
| 範囲内のすべてのドキュメントを受信者シャードに移動します。 |
|
| 3 つのサブ範囲を作成します。
|
|
| 2 つのサブ範囲を作成します。
|
|
| 2 つのサブ範囲を作成します。
|
min を指定するが、max は指定しない
次の表は、 minをさまざまな値に設定した結果を示しています。
min | キー範囲内のデータ量 | 結果 |
|---|---|---|
| キー | 範囲内のすべてのドキュメントを受信者シャードに移動します。 |
| キー | 2 つのサブ範囲を作成します。
|
| キー | 3 つのサブ範囲を作成します。
|
max を指定するが、min は指定しない
次の表は、 maxをさまざまな値に設定した結果を示しています。
max | キー範囲内のデータ量 | 結果 |
|---|---|---|
| キー | 範囲内のすべてのドキュメントを受信者シャードに移動します。 |
| キー | 2 つのサブ範囲を作成します。
|
| キー | 3 つのサブ範囲を作成します。
|