DBAtlas · 데이터베이스 운영 아틀라스

jumbo chunk 찾기, 분할, 플래그 해제

MongoDB샤딩

명령어

// Chunks flagged as jumbo (5.0+ config.chunks links to the collection by uuid):
const uuid = db.getSiblingDB("config").collections.findOne({ _id: "shop.musteri" }).uuid;
db.getSiblingDB("config").chunks.find({ uuid: uuid, jumbo: true }, { min: 1, max: 1, shard: 1 })
// If the chunk can be split, split it at the median:
sh.splitFind("shop.musteri", { musteriId: 1000 })
// Last resort for an indivisible chunk, clear the flag manually (a successful split already clears it):
db.adminCommand({ clearJumboFlag: "shop.musteri", find: { musteriId: 1000 } })
// If a single key value is too large, refine the key (4.4+):
db.adminCommand({ refineCollectionShardKey: "shop.musteri", key: { musteriId: 1, siparisId: 1 } })

하는 일

balancer가 이동하지 못해 jumbo로 표시된 chunk를 나열하고, 분할 가능한 것은 분할한 뒤 jumbo 플래그를 해제한다. 단일 값으로 된 거대한 chunk를 위한 샤드 키 refine 방법을 보여 준다.

사용 시점

한 샤드가 다른 샤드보다 눈에 띄게 큰 상태로 유지될 때, sh.status() 출력에 jumbo가 나타날 때, 또는 balancer가 마이그레이션 오류를 보고할 때.

주의

모든 문서가 같은 샤드 키 값을 가진 chunk는 분할할 수 없다. 지속적인 해결책은 refineCollectionShardKey 또는 reshardCollection으로 샤드 키를 바꾸는 것뿐이다. refineCollectionShardKey는 새 key를 지원하는 인덱스가 미리 있어야 한다. 분할 없이 jumbo 플래그만 해제하면 balancer가 같은 chunk를 다시 시도하고 또 실패한다.

DBAtlas에서 열기 →

관련 항목