mongodb 平衡器不会停止

mongodb balancer won't stop

重新启动分片集群后,我注意到平衡器不再迁移任何数据,但命令 sh.isBalancerRunning() 始终返回 true。

我尝试 运行 命令 sh.stopBalancer() 但它永远停留在:

sh.stopBalancer()
Waiting for active hosts...
Waiting for the balancer lock...

检查这里的配置服务器锁是数据:

configsvr> db.locks.find({_id: "balancer"})
{ "_id" : "balancer", "process" : "myserver.mongodb.com:27017:1452776409:1804289383", 
"state" : 2, "ts" : ObjectId("56cb817f2c4edd1226d6ae07"), "when" : ISODate("2016-02-22T21:45:35.360Z"), "who" : "myserver.mongodb.com:27017:1452776409:1804289383:Balancer:846930886", 
"why" : "doing balance round" }

此外,如果我尝试 运行 sh.startBalancer() 它会超时:

mongos> sh.startBalancer()
2016-02-23T22:51:11.204-0500 E QUERY    [thread1] Error: assert.soon failed, msg:Waited too long for lock balancer to change to state undefined :
doassert@src/mongo/shell/assert.js:15:14
assert.soon@src/mongo/shell/assert.js:200:13
sh.waitForDLock@src/mongo/shell/utils_sh.js:171:1
sh.waitForBalancer@src/mongo/shell/utils_sh.js:264:9
sh.startBalancer@src/mongo/shell/utils_sh.js:146:5
@(shell):1:1

sh.status():

balancer:
  Currently enabled:  yes
  Currently running:  yes
    Balancer lock taken at Mon Feb 22 2016 16:45:35 GMT-0500 (EST) by myserver.mongodb.com:27017:1452776409:1804289383:Balancer:846930886
    Balancer active window is set between 8:00 and 6:00 server local time
Failed balancer rounds in last 5 attempts:  5
Last reported error:  Connection refused
Time of Reported error:  Tue Feb 23 2016 17:27:26 GMT-0500 (EST)
Migration Results for the last 24 hours:
    No recent migrations

我已经尝试重新启动服务器,降低初选,将 locks balancer state 更改为 0 和 运行ning sh.startBalancer() 并删除 balancer 字段从锁数据库中再次尝试 运行 sh.startBalancer() 但没有结果。

最后是服务器时钟不同步的问题,由于某种原因直到第二天才出现有关此问题的日志。

希望这对遇到类似问题的人有所帮助:)