Balancer均衡器时段设置
1、查看 Balancer 进程是否开启
mongos> use config ##连接到config数据库
switched to db config
mongos> sh.getBalancerState()
true
2、停 Balancer 进程
mongos> sh.stopBalancer();
{ "ok" : 1 }
mongos> sh.getBalancerState();
false
3、开启 Balancer 进程
mongos> sh.startBalancer();
{ "ok" : 1 }
mongos> sh.getBalancerState();
true
4、设置 Balancer 进程运行时间窗口
默认情况下Balancing 进程时时在运行 为了降低 Balancing 进程对系统的影响,也可以设置Balancer 进程的运行时间窗口,让 Balancer 进程在指定时间窗口操作。
mongos> db.settings.update({ _id : "balancer" }, { $set : { activeWindow : { start : "23:00", stop : "6:00" } } }, true ) ;
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
mongos> db.settings.find();
{ "_id" : "balancer", "stopped" : false, "mode" : "full", "activeWindow" : { "start" : "23:00", "stop" : "6:00" } }
备注:以上设置 balancer 进程在 23:00 到 6:00 时间窗口执行,如果要设置时间窗口,确保
在指定时间段内能够完成数据分布。
5、删除 Balancer 进程运行时间窗口
mongos> db.settings.update({ "_id" : "balancer" }, { $unset : { activeWindow : 1 }});
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
mongos> db.settings.find();
{ "_id" : "balancer", "stopped" : false, "mode" : "full" }
6、实操过程
好了,这就是Balancer均衡器时段设置的方法了,如有问题可与博主一起交流讨论!