정의
mergeChunksFor a sharded collection,
mergeChunkscombines contiguous chunk ranges on a shard into a single chunk. Issue themergeChunkscommand on theadmindatabase from amongosinstance.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
- 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> } ] } )
명령 필드
이 명령은 다음 필드를 사용합니다.
액세스 제어
authorization 으로 실행되는 배포에서 기본 제공 역할 clusterManager 필요한 권한을 제공합니다.
행동
참고
Use the mergeChunks only in special circumstances. For instance, when cleaning up your sharded cluster after removing many documents.
청크를 성공적으로 병합하려면 다음 조건에 부합 해야 합니다.
bounds필드에서<minkey>과<maxkey>은 병합할 청크 의 하한 및 상한에 해당해야 합니다.청크는 동일한 샤드에 있어야 합니다.
청크는 연속적이어야 합니다.
mergeChunks 이러한 조건이 충족되지 않으면 오류를 반환합니다.
메시지 반환
On success, mergeChunks returns this document:
{ "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1510767081, 1), "signature" : { "hash" : BinData(0,"okKHD0QuzcpbVQg7mP2YFw6lM04="), "keyId" : Long("6488693018630029321") } }, "operationTime" : Timestamp(1510767081, 1) }
다른 작업 진행 중
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.
다양한 샤드의 청크
If the input chunks are not on the same shard, 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" : Long("6488693018630029321") } }, "operationTime" : Timestamp(1510767081, 1) }
비연속적인 청크
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" : Long("6488693018630029321") } }, "operationTime" : Timestamp(1510767081, 1) }