정의
moveChunkInternal administrative command. Moves chunks between shards. Issue the
moveChunkcommand via amongosinstance while using the admin database. Use the following forms:팁
In
mongosh, this command can also be run through thesh.moveChunk()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.db.adminCommand( { moveChunk : <namespace> , find : <query> , to : <ID of the recipient shard>, forceJumbo: <boolean>, _secondaryThrottle : <boolean>, writeConcern: <document>, _waitForDelete : <boolean> } ) 대신 다음을 사용할 수 있습니다.
db.adminCommand( { moveChunk : <namespace> , bounds : <array> , to : <ID of the recipient shard>, forceJumbo: <boolean>, _secondaryThrottle : <boolean>, writeConcern: <document>, _waitForDelete : <boolean> } ) 참고
listShards명령을 사용하여 수신자 샤드의 ID 조회.The
moveChunkcommand has the following fields:필드유형설명moveChunk문자열
청크 가 존재하는 collection 의 네임스페이스 입니다. 데이터베이스 이름을 포함하여 컬렉션의 전체 네임스페이스를 지정합니다.
find문서
이동할 청크의 샤드 키 값을 지정하는 샤드 키의 동등성 매치입니다.
bounds필드 또는find필드 중 하나만 지정하고 둘 다 지정하지는 않습니다. 해시 샤드 키 를사용하는 컬렉션에서 청크를 선택하는 데 필드를 사용하지 마세요 .findbounds배열
이동할 특정 청크의 경계입니다. 배열은 이동할 청크의 하위 및 상위 샤드 키 값을 지정하는 두 개의 문서로 구성되어야 합니다.
bounds필드 또는find필드 중 하나만 지정하고 둘 다 지정하지는 않습니다.bounds를 사용하여 해시 샤드 키를 사용하는 컬렉션에서 청크를 선택합니다.to문자열
청크 에 대한 수신자 샤드 의 ID .
부울
선택 사항. 명령 이 마이그레이션하기에는 너무 큰 청크를 이동할 수 있는지 여부를 결정하는 플래그입니다. 청크에는 점보 레이블이 지정되거나 표시되지 않을 수 있습니다.
true인 경우 명령은 청크를 이동할 수 있습니다.false인 경우 명령은 청크를 이동할 수 없습니다.
기본값은
false입니다.경고:
forceJumbo=true이 포함된moveChunk명령은 컬렉션 에 대한 쓰기 (write) 작업을 차단합니다.이 옵션을 사용하면 청크가 구성된 청크 크기보다 큰 경우에도 샤드 가 청크를 마이그레이션 합니다. 마이그레이션 기간 동안 컬렉션 쓰기를 사용할 수 없습니다.
긴 차단 기간 없이 이러한 큰 청크를 마이그레이션하려면 대신 크기 제한을 초과하는 범위 균형 조정 을 참조하세요.
_secondaryThrottle부울
선택 사항. WiredTiger 의 경우 기본값은
false입니다.true인 경우 기본적으로 청크 마이그레이션 중에 이동하는 각 문서는 밸런서가 다음 문서를 진행하기 전에 적어도 하나의 보조 문서로 전파됩니다. 이는{ w: 2 }의 쓰기 고려 (write concern)와 동일합니다.다른 쓰기 고려 (write concern)를 지정하려면
writeConcern옵션을 사용합니다.false인 경우 밸런서는 보조 문서로의 복제를 기다리지 않고 대신 다음 문서를 계속 진행합니다.
자세한 내용은 보조 스로틀을 참조하세요.
writeConcern문서
선택 사항. Express 청크 마이그레이션 중에
_secondaryThrottle가 세컨더리를 기다리는 데 사용할 쓰기 고려 (write concern) 를 문서입니다.writeConcern_secondaryThrottle: true가 필요합니다._waitForDelete부울
Optional. If set to
true, the delete phase of amoveChunkoperation is blocking._waitForDeletedefaults tofalse._waitForDelete필드가 설정되면 MongoDB는orphanCleanupDelaySecs지연을 기다리지 않고 범위 삭제를 수행합니다._waitForDelete매개 변수를 사용하고 세컨더리에서 읽기 작업이 발생하는 경우, 마이그레이션의 삭제 단계로 인해 읽기 시 문서가 누락될 수 있습니다.bounds의 값은 다음과 같은 형식을 취합니다.[ { hashedField : <minValue> } , { hashedField : <maxValue> } ] 청크 마이그레이션 섹션에서는 MongoDB의 샤드 간에 청크가 이동하는 방법을 설명합니다.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
- MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
고려 사항
Only use the moveChunk in special circumstances such as preparing your sharded cluster for an initial ingestion of data, or a large bulk import operation. In most cases allow the balancer to create and balance chunks in sharded clusters. See Create Ranges in a Sharded Cluster for more information.
행동
Indexes
moveChunk requires that all indexes exist on the target (i.e. to ) shard before migration and returns an error if a required index does not exist.
메타 데이터 오류
moveChunk 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 a balancer process, changes meta data while moveChunk is running, you may see this error. You may retry the moveChunk operation without side effects.
maxCatchUpPercentageBeforeBlockingWrites Server Parameter
MongoDB 부터는 를 설정하다 전송 중인 청크 5.0 의 maxCatchUpPercentageBeforeBlockingWrites moveChunk 총 크기(MB)와 비교했을 때 작업 중에 아직 마이그레이션되지 않은 데이터의 최대 허용 비율을 지정할 수 있습니다.