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

balancer 상태, 활성 window, 컬렉션별 밸런싱

MongoDB샤딩

명령어

// Is the balancer enabled, is it running a round right now:
sh.getBalancerState()
db.adminCommand({ balancerStatus: 1 })
// Run the balancer only between 01:00 and 05:00 (on mongos):
db.getSiblingDB("config").settings.updateOne({ _id: "balancer" }, { $set: { activeWindow: { start: "01:00", stop: "05:00" } } }, { upsert: true })
// Remove the window:
db.getSiblingDB("config").settings.updateOne({ _id: "balancer" }, { $unset: { activeWindow: true } })
// Disable / enable balancing for a single collection:
sh.disableBalancing("shop.musteri")
sh.enableBalancing("shop.musteri")
// Whether the collection is balanced (4.4+):
db.adminCommand({ balancerCollectionStatus: "shop.musteri" })

하는 일

balancer가 활성화되어 있고 라운드를 실행 중인지 보여 주고, chunk 마이그레이션을 시간 window로 제한하며, 단일 컬렉션의 밸런싱을 비활성화 또는 활성화한다.

사용 시점

chunk 마이그레이션이 주간 성능을 해칠 때, 백업 window 중, 또는 한 컬렉션의 마이그레이션 문제를 격리할 때.

주의

너무 좁은 window는 데이터 증가를 따라가지 못해 샤드가 불균형해지므로 balancerCollectionStatus로 정기적으로 균형을 확인한다. window가 닫히기 전에 시작된 마이그레이션은 끝날 때까지 실행된다. 컬렉션별 밸런싱을 비활성화한 채 두면 그 컬렉션은 단일 샤드에서 계속 커진다.

DBAtlas에서 열기 →

관련 항목