DBAtlas · データベース運用アトラス

バランサーの状態、アクティブウィンドウ、コレクション単位のバランシング

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" })

概要

バランサーが有効でラウンドを実行中かどうかを表示し、チャンクの移行を時間ウィンドウに制限し、単一コレクションのバランシングを無効化または有効化する。

使用する場面

チャンクの移行が日中の性能を損なう場合、バックアップウィンドウ中、または 1 つのコレクションで移行の問題を切り分ける場合。

注意

狭すぎるウィンドウではデータの増加に追いつけず、シャード間の偏りが生じる。balancerCollectionStatus で定期的にバランスを確認する。ウィンドウが閉じる前に開始された移行は完了するまで実行される。コレクション単位のバランシングを無効のままにすると、そのコレクションは単一のシャード上で増大し続ける。

DBAtlas で開く →

関連項目