Mongo分片维护之平衡器

查看balance 状态 

可以通过下面的命令来查看当前的balance进程状态。先连接到任意一台mongos

use config
db.locks.find( { _id : "balancer" } ).pretty()
{   "_id" : "balancer",
"process" : "mongos0.example.net:1292810611:1804289383",
  "state" : 2,
     "ts" : ObjectId("4d0f872630c42d1978be8a2e"),
   "when" : "Mon Dec 20 2010 11:41:10 GMT-0500 (EST)",
    "who" : "mongos0.example.net:1292810611:1804289383:Balancer:846930886",
    "why" : "doing balance round" }

  state=2 表示正在进行balance, 在2.0版本之前这个值是1

 

配置balance时间窗口

可以通过balance时间窗口指定在一天之内的某段时间之内可以进行balance, 其他时间不得进行balance。

先连接到任意一台mongos

use config
db.settings.update({ _id : "balancer" }, { $set : { activeWindow : { start : "23:00", stop : "6:00" } } }, true )

  这个设置让只有从23:00到6:00之间可以进行balance。

也可以取消时间窗口设置:

use config
db.settings.update({ _id : "balancer" }, { $unset : { activeWindow : true } })

  

posted @ 2014-12-25 10:52  qiuleo  阅读(586)  评论(0编辑  收藏  举报