我有一个mongoDB 4.0.1副本集,该副本集具有以下配置的4个节点
var cfg = {
"_id": "rs0",
"version": 1,
"members": [
{
"_id": 0,
"host": "mongo-1:27017",
"priority": 3
},
{
"_id": 1,
"host": "mongo-2:27017",
"priority": 2
},
{
"_id": 2,
"host": "mongo-3:27017",
"priority": 1
},
{
"_id": 3,
"host": "mongo-4:27017",
"arbiterOnly": true
}
]
};
rs.initiate(cfg, { force: true });
rs.reconfig(cfg, { force: true });
rs.status();
所有操作都在本地主机上,并且可以正常连接。我基本上是在测试,将主要的mongo-1降低(10-12秒后),因为优先级更高,其余节点选择一个新的理想的主要mongo-2。
但是,如果我卸下容器mongo-1,其他3个节点将继续尝试无限期地连接到mongo-1。我什至已经等了十多分钟,但所有日志显示都是尝试连接host-unreachable
等等。
如果任何人对我可能缺少的内容或未设置的配置有任何想法,请随时评论或提出解决此问题的方法。 谢谢!
编辑
这是我来自rs.status()
的输出,有点混乱,但可以用JSON格式器轻松读取:)
rs0:PRIMARY> rs.status() { “ set”:“ rs0”, “ date”:ISODate(“ 2018-10-27T00:47:23.582Z”), “ myState”:1 “ term”:NumberLong(4), “ syncingTo”:“”, “ syncSourceHost”:“”, “ syncSourceId”:-1, “ heartbeatIntervalMillis”:NumberLong(2000), “优化”:{ “ lastCommittedOpTime”:{ “ ts”:时间戳(1540601235,1), “ t”:NumberLong(4) }, “ readConcernMajorityOpTime”:{ “ ts”:时间戳(1540601235,1), “ t”:NumberLong(4) }, “ appliedOpTime”:{ “ ts”:时间戳(1540601235,1), “ t”:NumberLong(4) }, “ durableOpTime”:{ “ ts”:时间戳(1540601235,1), “ t”:NumberLong(4) } }, “ lastStableCheckpointTimestamp”:时间戳(1540601162,1), “成员”:[ { “ _id”:0, “ name”:“ mongo-1:27017”, “健康”:1, “状态”:1 “ stateStr”:“ PRIMARY”, “正常运行时间”:227, “ optime”:{ “ ts”:时间戳(1540601235,1), “ t”:NumberLong(4) }, “ optimeDate”:ISODate(“ 2018-10-27T00:47:15Z”), “ syncingTo”:“”, “ syncSourceHost”:“”, “ syncSourceId”:-1, “ infoMessage”:“找不到要同步的成员”, “ electionTime”:时间戳(1540601173,1), “ electionDate”:ISODate(“ 2018-10-27T00:46:13Z”), “ configVersion”:1 “自我”:是的, “ lastHeartbeatMessage”:“” }, { “ _id”:1 “ name”:“ mongo-2:27017”, “健康”:1, “状态”:2 “ stateStr”:“ SECONDARY”, “正常运行时间”:31, “ optime”:{ “ ts”:时间戳(1540601235,1), “ t”:NumberLong(4) }, “ optimeDurable”:{ “ ts”:时间戳(1540601235,1), “ t”:NumberLong(4) }, “ optimeDate”:ISODate(“ 2018-10-27T00:47:15Z”), “ optimeDurableDate”:ISODate(“ 2018-10-27T00:47:15Z”), “ lastHeartbeat”:ISODate(“ 2018-10-27T00:47:22.085Z”), “ lastHeartbeatRecv”:ISODate(“ 2018-10-27T00:47:22.295Z”), “ pingMs”:NumberLong(0), “ lastHeartbeatMessage”:“”, “ syncingTo”:“ mongo-1:27017”, “ syncSourceHost”:“ mongo-1:27017”, “ syncSourceId”:0, “ infoMessage”:“”, “ configVersion”:1 }, { “ _id”:2 “ name”:“ mongo-3:27017”, “健康”:1, “状态”:2 “ stateStr”:“ SECONDARY”, “正常运行时间”:225, “ optime”:{ “ ts”:时间戳(1540601235,1), “ t”:NumberLong(4) }, “ optimeDurable”:{ “ ts”:时间戳(1540601235,1), “ t”:NumberLong(4) }, “ optimeDate”:ISODate(“ 2018-10-27T00:47:15Z”), “ optimeDurableDate”:ISODate(“ 2018-10-27T00:47:15Z”), “ lastHeartbeat”:ISODate(“ 2018-10-27T00:47:21.677Z”), “ lastHeartbeatRecv”:ISODate(“ 2018-10-27T00:47:22.491Z”), “ pingMs”:NumberLong(0), “ lastHeartbeatMessage”:“”, “ syncingTo”:“ mongo-1:27017”, “ syncSourceHost”:“ mongo-1:27017”, “ syncSourceId”:0, “ infoMessage”:“”, “ configVersion”:1 }, { “ _id”:3, “ name”:“ mongo-4:27017”, “健康”:1, “状态”:7 “ stateStr”:“ ARBITER”, “正常运行时间”:225, “ lastHeartbeat”:ISODate(“ 2018-10-27T00:47:21.657Z”), “ lastHeartbeatRecv”:ISODate(“ 2018-10-27T00:47:21.804Z”), “ pingMs”:NumberLong(0), “ lastHeartbeatMessage”:“”, “ syncingTo”:“”, “ syncSourceHost”:“”, “ syncSourceId”:-1, “ infoMessage”:“”, “ configVersion”:1 } ], “ ok”:1 “ operationTime”:时间戳记(1540601235,1), “ $ clusterTime”:{ “ clusterTime”:时间戳记(1540601235,1), “签名”:{ “哈希”:BinData(0,“ AAAAAAAAAAAAAAAAAAAAAAAAAAA =”), “ keyId”:NumberLong(0) } } }