Balancer均衡器时段设置

本文详细介绍了在MongoDB中如何控制Balancer进程的运行时间,包括启动、停止及设定特定时段运行的方法,有助于优化系统性能并减少对日常业务的影响。

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均衡器时段设置的方法了,如有问题可与博主一起交流讨论!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值