moveRange
定義
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです
注意
このコマンドは、すべての MongoDB Atlas クラスターでサポートされています。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。
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。 |
| キー | Minimum key of the range to move. Required if you don't specify
If you do not specify
|
| キー | Maximum key of the range to move. Required if you don't specify
If you do not specify
|
ブール値 | 任意。 Flag that determines if the command can move a range that is too large to migrate. The range may or may not be labeled as jumbo.
デフォルトは 警告: The This option causes the shard to migrate chunks even when they are larger than the configured chunk size. The collection remains unavailable for writes for the duration of the migration. To migrate these large chunks without this long blocking period, see Balance Ranges that Exceed Size Limit instead. | |
| ドキュメント | |
| ブール値 | 任意。
For more information, see Secondary Throttle. |
The range migration section describes how ranges move between shards on MongoDB.
Considerations
Only use the moveRange
in scenarios like:
an initial ingestion of data
a large bulk import operation
Allow the balancer to create and balance ranges in sharded clusters in most cases.
例
The following examples use a collection with:
Shard key
x
Configured chunk size of 128MB
A chunk with boundaries:
[x: 0, x: 100)
Specify both min
and max
The following table lists the results of setting min
and max
to various values:
min | max | 結果 |
---|---|---|
|
| Moves all the documents in the range to the recipient shard. |
|
| Creates three sub-ranges:
Moves all the documents in |
|
| Creates two sub-ranges:
Moves all the documents in |
|
| Creates two sub-ranges:
Moves all the documents in |
Specify min
but not max
The following table lists the results of setting min
to various
values:
min | Amount of Data in Key Range | 結果 |
---|---|---|
| Less than 128 MB contained between keys | Moves all the documents in the range to the recipient shard. |
| Less than 128 MB contained between keys | Creates two sub-ranges:
Moves all documents in |
| 128 MB contained between keys | Creates three sub-ranges:
Moves all documents in |
Specify max
but not min
The following table lists the results of setting max
to various
values:
max | Amount of Data in Key Range | 結果 |
---|---|---|
| Less than 128 MB contained between keys | Moves all the documents in the range to the recipient shard. |
| Less than 128 MB contained between keys | Creates two sub-ranges:
Moves all documents in |
| 128 MB contained between keys | Creates three sub-ranges:
Moves all documents in |