mergeChunks
定義
mergeChunks
For a sharded collection,
mergeChunks
combines contiguous チャンク ranges on a shard into a single chunk. Issue themergeChunks
command on theadmin
database from amongos
instance.
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです
重要
このコマンドはサーバーレスインスタンスではサポートされていません。 詳細については、「サポートされていないコマンド 」を参照してください。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
構文
このコマンドの構文は、次のとおりです。
db.adminCommand( { mergeChunks: <namespace>, bounds : [ { <shardKeyField>: <minFieldValue> }, { <shardKeyField>: <maxFieldValue> } ] } )
For compound shard keys, you must include the full shard key in the
bounds
specification. For example, if the shard key is { x: 1, y:
1 }
, mergeChunks
has the following form:
db.adminCommand( { mergeChunks: <namespace>, bounds: [ { x: <minValue>, y: <minValue> }, { x: <maxValue>, y: <maxValue> } ] } )
コマンドフィールド
このコマンドは、次のフィールドを使用します。
アクセス制御
On deployments running with authorization
, the
built-in role clusterManager
provides the required
privileges.
動作
注意
Use the mergeChunks
only in special circumstances. For
instance, when cleaning up your シャーディングされたクラスター after removing
many documents.
In order to successfully merge chunks, the following must be true:
In the
bounds
field,<minkey>
and<maxkey>
must correspond to the lower and upper bounds of the chunks to merge.The chunks must reside on the same shard.
The chunks must be contiguous.
mergeChunks
returns an error if these conditions are not
satisfied.
Return Messages
On success, mergeChunks
returns this document:
{ "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1510767081, 1), "signature" : { "hash" : BinData(0,"okKHD0QuzcpbVQg7mP2YFw6lM04="), "keyId" : NumberLong("6488693018630029321") } }, "operationTime" : Timestamp(1510767081, 1) }
Another Operation in Progress
mergeChunks
returns the following error message if another
metadata operation is in progress on the chunks
collection:
errmsg: "The collection's metadata lock is already taken."
If another process, such as balancer process, changes metadata while
mergeChunks
is running, you may see this error. You can
retry the mergeChunks
operation without side effects.
Chunks on Different Shards
If the input chunks are not on the same シャード,
mergeChunks
returns an error similar to the following:
{ "ok" : 0, "errmsg" : "could not merge chunks, collection test.users does not contain a chunk ending at { username: \"user63169\" }", "$clusterTime" : { "clusterTime" : Timestamp(1510767081, 1), "signature" : { "hash" : BinData(0,"okKHD0QuzcpbVQg7mP2YFw6lM04="), "keyId" : NumberLong("6488693018630029321") } }, "operationTime" : Timestamp(1510767081, 1) }
Noncontiguous Chunks
If the input chunks are not contiguous,
mergeChunks
returns an error similar to the following:
{ "ok" : 0, "errmsg" : "could not merge chunks, collection test.users has more than 2 chunks between [{ username: \"user29937\" }, { username: \"user49877\" })" "$clusterTime" : { "clusterTime" : Timestamp(1510767081, 1), "signature" : { "hash" : BinData(0,"okKHD0QuzcpbVQg7mP2YFw6lM04="), "keyId" : NumberLong("6488693018630029321") } }, "operationTime" : Timestamp(1510767081, 1) }