MongoDB分片集群之balance运维
2021-04-19 14:19
946 查看
查看mongo集群是否开启了balance
mongos> sh.getBalancerState() true
查看是否正在有数据的迁移
mongos> sh.isBalancerRunning() false
设置balance时间窗口
mongos> use config switched to db config mongos> db.settings.update({ _id : "balancer" }, { $set : { activeWindow : { start : "00:00", stop : "5:00" } } }, true ) WriteResult({ "nMatched" : 0, "nUpserted" : 1, "nModified" : 0, "_id" : "balancer" })
查看balance时间窗口
mongos> db.settings.find() { "_id" : "balancer", "activeWindow" : { "start" : "00:00", "stop" : "5:00" } }
停止balance
mongos> sh.stopBalancer() { "ok" : 1, "operationTime" : Timestamp(1618812138, 3), "$clusterTime" : { "clusterTime" : Timestamp(1618812138, 3), "signature" : { "hash" : BinData(0,"gjGNaEdpTSZLmXRTVemQwphnW2Q="), "keyId" : NumberLong("6941260985399246879") } } } mongos> mongos> mongos> sh.getBalancerState() false
重新打开balance
mongos> sh.setBalancerState(true) { "ok" : 1, "operationTime" : Timestamp(1618812177, 3), "$clusterTime" : { "clusterTime" : Timestamp(1618812177, 3), "signature" : { "hash" : BinData(0,"U6MqfK6GmY8Bv3jMRZbCJTJPZdY="), "keyId" : NumberLong("6941260985399246879") } } } mongos> sh.getBalancerState() true
删除balance时间窗口
mongos> use config switched to db config mongos> db.settings.update({ _id : "balancer" }, { $unset : { activeWindow : true } }) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) mongos> mongos> db.settings.find() { "_id" : "balancer", "mode" : "full", "stopped" : false } { "_id" : "autosplit", "enabled" : true }
相关文章推荐
- MongoDB的分片集群配置
- mongodb 集群分片
- 配置MongoDB3.04集群分片
- mongodb sharding cluster(分片集群)
- MongoDB 分片集群理解图
- TiDB和MongoDB分片集群架构比较
- MongoDB分片集群的备份和恢复(使用mongodump&mongorestore)
- MongoDB 分片集群搭建
- mongodb集群分片+副本模式操作+javaCode
- Mongodb Replica Sets + Sharding 分片集群架构部署
- 如何部署MongoDB分片集群?
- mongodb 集群搭建 分片+副本集
- mongodb学习记录---集群分片Shard_1
- Mongodb 分片集群部署
- 安装mongodb副本分片集群
- [原创]在Docker上部署mongodb分片副本集群。
- mongodb分片集群突然停电造成一些错误,分片无法启动
- windows下mongodb分片设置与集群搭建
- 【MongoDB】在windows平台下mongodb的分片集群(五)
- MongoDB水平分片集群学习笔记