mongoDB-3.x Balancer Management

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 } )
mongoDB-3.x <wbr>Balancer <wbr>Management

3.Check the Balancer State
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(
   { _id: "balancer" },
   { $set: { activeWindow : { start : "01", stop : "06" } } },
   { upsert: true }
)
db.settings.find()
mongoDB-3.x <wbr>Balancer <wbr>Management
时间格式:
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")
posted @ 2016-01-14 08:54  李庆喜  阅读(158)  评论(0编辑  收藏  举报