mongoDB-3.x Balancer Management
1.Chunk
Size
use config
db.settings.save( { _id:"chunksize", value: 64 } )
范围:1-1024,单位MB
2.Maximum
Storage Size
use config
db.runCommand( { addshard : "example.net:34008", maxSize : 125
} )
sh.getBalancerState()
4.Check the
Balancer Lock
use config
db.locks.find( { _id : "balancer" } ).pretty()
5.Schedule
the Balancing Window
use config
sh.setBalancerState( true )
db.settings.update(
)
db.settings.find()
时间格式:
For HH values, use hour values ranging from 00 -
23
For MM value, use minute values ranging from 00 -
59
6.Remove a
Balancing Window Schedule
use config
db.settings.update({ _id : "balancer" }, { $unset : {
activeWindow : true } })
7.Enable/Disable the Balancer
sh.startBanlancer()或sh.setBalancerState(true)或
db.settings.update( { _id:
"balancer" }, { $set : { stopped: false } } , {
upsert: true } )
sh.stopBalancer()或sh.setBalancerState(false)或
db.settings.update( { _id: "balancer" }, { $set : { stopped:
true } } , { upsert: true } )
8.Disable
Balancing During Backups
!sh.getBalancerState() &&
!sh.isBalancerRunning()
9.Enable/Disable Balancing on a
Collection
sh.disableBalancing("students.grades")
sh.enableBalancing("students.grades")