정의
removeShard경고
MongoDB 8.3부터
removeShard명령은 더 이상 사용되지 않으며 향후 출시하다 에서 제거될 예정입니다.샤드 배출 프로세스 다음 명령으로 대체되었습니다.
샤드 비워지면
commitShardRemoval명령을 사용하여 제거할 수 있습니다.자세한 내용은 샤드 클러스터에서 샤드 제거를 참조하세요.
샤딩된 클러스터에서 샤드 제거합니다.
removeShard를 실행 MongoDB 밸런서 를 사용하여 샤드의 청크를 클러스터 의 다른 샤드로 이동하여 샤드 를 비웁니다.참고
완료하려면
removeShard밸런서 활성화해야 합니다. 밸런서 비활성화된 경우, 이미 샤드 에서 모든 데이터를 이동했더라도 명령은 배출 상태 로 유지되며 완료되지 않습니다.샤드 에 샤딩되지 않은 컬렉션이 있는 경우 샤드 에서 샤딩되지 않은 컬렉션을 모두 배출해야 합니다. MongoDB 8.0부터는
sh.moveCollection()를 사용하여 샤딩되지 않은 컬렉션을 이동할 수 있습니다. 샤드 비우는 절차에 대한 자세한 내용은 샤드 클러스터에서 샤드 제거를 참조하세요.샤드 비워지면 MongoDB 클러스터 에서 샤드 제거합니다.
참고
제거된 샤드 샤딩된 클러스터 에 다시 추가하려면
storage.dbPath샤드를 다시 추가하기 전에 샤드 의 모든 노드에서 를 지워서 샤드의 파일을 제거 해야 합니다.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
참고
This command is not supported in MongoDB Atlas. See Modify your Atlas Sharded Cluster to add or remove shards from your Atlas cluster.
구문
명령은 다음과 같은 구문을 가집니다:
db.adminCommand( { removeShard : <shardToRemove> } )
행동
샤드 제거 중 cluster 백업 없음
샤드 제거 중에는 cluster 데이터를 백업할 수 없습니다.
동시 removeShard 작업
You can have more than one removeShard operation in progress.
액세스 요구 사항
authorization 을(를) 활성화한 경우 clusterManager 역할 또는 removeShard 작업을 포함하는 역할이 있어야 합니다.
데이터베이스 마이그레이션 요구 사항
샤드 샤딩된 클러스터 의 각 데이터베이스 에는 프라이머리 샤드 가 있습니다. 제거 하려는 샤드 가 클러스터 데이터베이스 중 하나의 프라이머리 이기도 한 경우, 샤드 에서 모든 데이터를 마이그레이션한 후 데이터베이스를 새 샤드 로 수동으로 이동해야 합니다. 자세한 내용은 movePrimary 명령 및 샤드 클러스터에서 샤드 제거 를 참조하세요.
청크 밸런싱
청크 분포가 균일하지 않은 클러스터에서 샤드를 제거하면 밸런서는 먼저 드레이닝 샤드에서 청크를 제거한 다음 나머지 불균등 청크 분포를 조정합니다.
쓰기 고려
mongos converts the write concern of the removeShard command to "majority".
변경 스트림
샤드 를 제거하면 열려 있는 변경 스트림 커서 가 닫힐 수 있으며, 닫힌 변경 스트림 커서 가 완전히 재개되지 않을 수 있습니다.
DDL 작업
클러스터 가 DDL 작업(예: 컬렉션 을 수정하는 작업 reshardCollection)을 실행하는 동안 removeShard 를 실행 하는 경우, removeShard 는 동시 DDL 작업이 완료된 후에만 실행됩니다.
예시
From mongosh, the removeShard operation resembles the following:
db.adminCommand( { removeShard : "bristol01" } )
Replace bristol01 with the name of the shard to remove. When you run removeShard, the command returns with a message that resembles the following:
{ "msg" : "draining started successfully", "state" : "started", "shard" : "bristol01", "note" : "you need to call moveCollection for collectionsToMove and afterwards movePrimary for the dbsToMove", "dbsToMove" : [ "fizz", "buzz" ], "collectionsToMove" : [ "fizz.coll1", "buzz.coll1" ], "ok" : 1, "operationTime" : Timestamp(1575398919, 2), "$clusterTime" : { "clusterTime" : Timestamp(1575398919, 2), "signature" : { "hash" : BinData(0,"Oi68poWCFCA7b9kyhIcg+TzaGiA="), "keyId" : Long("6766255701040824328") } } }
밸런서가 bristol01 이라는 이름의 샤드에서 클러스터의 다른 샤드로 청크를 마이그레이션(이동)하기 시작합니다(이는 "배출"). 이러한 마이그레이션은 클러스터에 과도한 부하를 주지 않기 위해 느리게 수행됩니다.
If you run the command again, removeShard returns the current status of the process. For example, if the operation is in an ongoing state, the command returns an output that resembles the following:
{ "msg" : "draining ongoing", "state" : "ongoing", "remaining" : { "chunks" : Long(2), "dbs" : Long(2), "jumboChunks" : Long(0), "collectionsToMove": Long(2) }, "note" : "you need to call moveCollection for collectionsToMove and afterwards movePrimary for the dbsToMove", "dbsToMove" : [ "fizz", "buzz" ], "collectionsToMove" : [ "fizz.coll1", "buzz.coll1" ], "ok" : 1, "operationTime" : Timestamp(1575399086, 1655), "$clusterTime" : { "clusterTime" : Timestamp(1575399086, 1655), "signature" : { "hash" : BinData(0,"XBrTmjMMe82fUtVLRm13GBVtRE8="), "keyId" : Long("6766255701040824328") } } }
출력에서 remaining 필드에는 다음 필드가 포함됩니다.
필드 | 설명 |
|---|---|
| 현재 샤드에 남아 있는 청크의 총 개수입니다. |
| 프라이머리 샤드가 샤드인 데이터베이스의 총 개수입니다. 이러한 데이터베이스는 |
| 전체
|
| 샤드 에서 이동해야 하는 샤딩되지 않은 컬렉션의 총 개수입니다. |
| 제거 진행 중인 샤드에 남은 예상 바이트 수. |
transitionToDedicatedConfigServer가 실행될 때, removeShard 출력에는 다음 필드가 포함될 수 있습니다. 이 필드는 밸런서가 config 서버에서 모든 청크 및 데이터베이스를 이동한 후에만 나타납니다.
필드 | 설명 |
|---|---|
| 제거 중인 샤드에 남아 있는 보류 중인 범위 삭제 횟수입니다. |
| 제거 진행 중인 샤드에서의 첫 번째로 비어 있지 않은 컬렉션입니다. |
Continue checking the status of the removeShard command (that is, rerun the command) until the number of chunks remaining is 0.
{ "msg" : "draining ongoing", "state" : "ongoing", "remaining" : { "chunks" : Long(0), // All chunks have moved "dbs" : Long(2), "jumboChunks" : Long(0), "collectionsToMove": Long(2) }, "note" : "you need to call moveCollection for collectionsToMove and afterwards movePrimary for the dbsToMove", "dbsToMove" : [ "fizz", "buzz" ], "collectionsToMove" : [ "fizz.coll1", "buzz.coll1" ], "ok" : 1, "operationTime" : Timestamp(1575400343, 1), "$clusterTime" : { "clusterTime" : Timestamp(1575400343, 1), "signature" : { "hash" : BinData(0,"9plu5B/hw4uWAgEmjjBP3syw1Zk="), "keyId" : Long("6766255701040824328") } } }
밸런서 샤드 에서 모든 청크를 비운 후에는 컬렉션과 데이터베이스를 비워진 샤드 밖으로 수동으로 이동해야 할 수 있습니다.
If the removeShard 출력에 collectionsToMove 필드 의 컬렉션이 포함된 경우 moveCollection 를 사용하여 해당 컬렉션을 배출 샤드 이외의 샤드 로 이동하거나 컬렉션을 삭제(관련 데이터 파일 삭제)합니다.
removeShard 출력에 dbsToMove 필드의 데이터베이스가 포함된 경우 해당 데이터베이스에 movePrimary 를 사용하거나 데이터베이스를 삭제(관련 데이터 파일 삭제)합니다.
참고
최상의 성능을 얻으려면 데이터베이스를 이동하기 전에 컬렉션을 이동하세요.
After the balancer completes moving all chunks off the shard and you have handled the dbsToMove and collectionsToMove, removeShard can finish. Running removeShard again returns output that resembles the following:
{ "msg" : "removeshard completed successfully", "state" : "completed", "shard" : "bristol01", "ok" : 1, "operationTime" : Timestamp(1575400370, 2), "$clusterTime" : { "clusterTime" : Timestamp(1575400370, 2), "signature" : { "hash" : BinData(0,"JjSRciHECXDBXo0e5nJv9mdRG8M="), "keyId" : Long("6766255701040824328") } } }