我正在尝试通过Apache Mesos和Marathon构建可扩展的ReplicaSet。因此,我创建了一个Docker文件,其中包含MongoDB 3.0.7和一个Node.js应用程序,该应用程序将自己注册到marathon的eventSubscriptions
API,这意味着它会对来自Marathon的事件作出反应。
这些是由应用程序过滤的,例如,当第一个节点启动时触发ReplicaSet init,并在下一个节点出现时将成员添加到ReplicaSet。
初始化工作完美无缺,但当我尝试将下一个节点添加到ReplicaSet时,MongoDB报告错误:
2015-10-22T08:52:58.639+0000 I REPL [conn18] replSetReconfig admin command received from client
2015-10-22T08:52:58.641+0000 W NETWORK [conn18] Failed to connect to 192.168.200.167:31069, reason: errno:111 Connection refused
2015-10-22T08:52:58.641+0000 I REPL [conn18] replSetReconfig config object with 2 members parses ok
2015-10-22T08:52:58.641+0000 W NETWORK [ReplExecNetThread-0] Failed to connect to 192.168.200.167:31069, reason: errno:111 Connection refused
2015-10-22T08:52:58.691+0000 W REPL [ReplicationExecutor] Failed to complete heartbeat request to 192.168.200.167:31069; Location18915 Failed attempt to connect to 192.168.200.167:31069; couldn't connect to server 192.168.200.167:31069 (192.168.200.167), connection attempt failed
2015-10-22T08:52:58.691+0000 E REPL [conn18] replSetReconfig failed; NodeNotFound Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: 192.168.200.168:31970; the following nodes did not respond affirmatively: 192.168.200.167:31069 failed with Failed attempt to connect to 192.168.200.167:31069; couldn't connect to server 192.168.200.167:31069 (192.168.200.167), connection attempt failed
我尝试验证连接是否有效,并且我可以成功连接到给定的连接信息:
$mongo --host 192.168.200.167 --port 31069
MongoDB shell version: 3.0.7
connecting to: 192.168.200.167:31069/test
Server has startup warnings:
2015-10-22T08:52:59.212+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
>
所以,对我而言,连接似乎就在那里。接下来我检查了我为重新配置ReplicaSet而创建的新ReplicaSet配置是否正常工作:
{
"_id": "rs0",
"version": 2,
"members": [
{
"_id": 0,
"host": "192.168.200.168:31970",
"arbiterOnly": false,
"buildIndexes": true,
"hidden": false,
"priority": 1,
"tags": {},
"slaveDelay": 0,
"votes": 1
},
{
"_id": 1,
"host": "192.168.200.167:31069"
}
],
"settings": {
"chainingAllowed": true,
"heartbeatTimeoutSecs": 30,
"getLastErrorModes": {},
"getLastErrorDefaults": {
"w": 1,
"wtimeout": 0
}
}
}
此配置通过发出
执行db.admin().command({replSetReconfig: myConfig}, function(error, newConfigResult) { ... });
此配置触发MongoDB日志中的上述错误,以及Node.js应用程序日志中的以下错误:
{
"name": "MongoError",
"message": "Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: 192.168.200.168:31970; the following nodes did not respond affirmatively: 192.168.200.167:31069 failed with Failed attempt to connect to 192.168.200.167:31069; couldn't connect to server 192.168.200.167:31069 (192.168.200.167), connection attempt failed",
"ok": 0,
"errmsg": "Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: 192.168.200.168:31970; the following nodes did not respond affirmatively: 192.168.200.167:31069 failed with Failed attempt to connect to 192.168.200.167:31069; couldn't connect to server 192.168.200.167:31069 (192.168.200.167), connection attempt failed",
"code": 74
}
现在,事件更奇怪的是,如果我使用配置并通过
直接在主要的MongoDB shell上运行它db.runCommand({replSetReconfig: myConfigFromAbove});
它也有效......有人知道可能是什么问题吗?非常感谢提前!