mongo分片后 ,数据只存在一个shard中

mongo在储存数据后,所有的数据全部存在了一个 shard中, 另两个 shard 是没问题的,

 原因:

            use config;

            db.settings.find();

           查看setting的状态:

    mongos> db.settings.find()
                              { "_id" : "chunksize", "value" : NumberLong(64) }
                              { "_id" : "balancer", "stopped" : false } 

           如果 stopped是true,改为false就行了, balancer也可以设置分片时间   

 

--2 查看 Balancer 进程详细信息

 

 [shard@redhatB ~]$ mongo 127.0.0.1:7282/config
MongoDB shell version: 2.2.1
connecting to: 127.0.0.1:7282/config

mongos> db.locks.find( { _id : "balancer" } ).pretty();
{
        "_id" : "balancer",
        "process" : "redhatB.example.com:7282:1355471954:1804289383",
        "state" : 0,
        "ts" : ObjectId("50d11adc2f9d8a6566923017"),
        "when" : ISODate("2012-12-19T01:39:40.448Z"),
        "who" : "redhatB.example.com:7282:1355471954:1804289383:Balancer:846930886",
        "why" : "doing balance round"
}

   
        
--3 查看 Balancer 进程是否开启   

 

 

 mongos> sh.getBalancerState();
true  

    备注:连接到 config 库操作。

 

 

--4 停 Balancer 进程

 

 mongos> sh.stopBalancer();
Waiting for active hosts...
Waiting for the balancer lock...
Waiting again for active hosts after balancer is off...

mongos> sh.getBalancerState();
false

    备注:连接到 config 库操作。

 

 

--5 开启 Balancer 进程

 

 mongos> sh.startBalancer();
mongos> sh.getBalancerState();
true

    备注:连接到 config 库操作。
  
  
--6  设置 Balancer 进程运行时间窗口
    默认情况下Balancing 进程时时在运行 为了降低 Balancing 进程对系统的影响,也可以设置
 Balancer 进程的运行时间窗口,让 Balancer 进程在指定时间窗口操作。

 

 

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

mongos> db.settings.find();
{ "_id" : "balancer", "activeWindow" : { "start" : "23:00", "stop" : "6:00" }, "stopped" : false }

    备注:以上设置 balancer 进程在 23:00 到 6:00 时间窗口执行,如果要设置时间窗口,确保
             在指定时间段内能够完成数据分布。
  
  
--7  删除 Balancer 进程运行时间窗口

 

 

 

 mongos> db.settings.update({ "_id" : "balancer" }, { $unset : { activeWindow : 1 }});

mongos> db.settings.find();
{ "_id" : "chunksize", "value" : 10 }
{ "_id" : "balancer", "stopped" : false }

    

 

转载于:https://www.cnblogs.com/redBack/p/9223142.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值