0

我有 4 个节点设置的 mongoDB 4.0.1 副本集,配置如下

  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。我什至等了 10 多分钟,但所有日志显示都是尝试连接host-unreachable等等。

如果有人对我可能遗漏的内容或我未设置的配置有任何想法,请随时评论或建议解决此问题的方法。谢谢!

编辑 这是我的输出rs.status()

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),
    "optimes" : {
        "lastCommittedOpTime" : {
            "ts" : Timestamp(1540601235, 1),
            "t" : NumberLong(4)
        },
        "readConcernMajorityOpTime" : {
            "ts" : Timestamp(1540601235, 1),
            "t" : NumberLong(4)
        },
        "appliedOpTime" : {
            "ts" : Timestamp(1540601235, 1),
            "t" : NumberLong(4)
        },
        "durableOpTime" : {
            "ts" : Timestamp(1540601235, 1),
            "t" : NumberLong(4)
        }
    },
    "lastStableCheckpointTimestamp" : Timestamp(1540601162, 1),
    "members" : [
        {
            "_id" : 0,
            "name" : "mongo-1:27017",
            "health" : 1,
            "state" : 1,
            "stateStr" : "PRIMARY",
            "uptime" : 227,
            "optime" : {
                "ts" : Timestamp(1540601235, 1),
                "t" : NumberLong(4)
            },
            "optimeDate" : ISODate("2018-10-27T00:47:15Z"),
            "syncingTo" : "",
            "syncSourceHost" : "",
            "syncSourceId" : -1,
            "infoMessage" : "could not find member to sync from",
            "electionTime" : Timestamp(1540601173, 1),
            "electionDate" : ISODate("2018-10-27T00:46:13Z"),
            "configVersion" : 1,
            "self" : true,
            "lastHeartbeatMessage" : ""
        },
        {
            "_id" : 1,
            "name" : "mongo-2:27017",
            "health" : 1,
            "state" : 2,
            "stateStr" : "SECONDARY",
            "uptime" : 31,
            "optime" : {
                "ts" : Timestamp(1540601235, 1),
                "t" : NumberLong(4)
            },
            "optimeDurable" : {
                "ts" : Timestamp(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",
            "health" : 1,
            "state" : 2,
            "stateStr" : "SECONDARY",
            "uptime" : 225,
            "optime" : {
                "ts" : Timestamp(1540601235, 1),
                "t" : NumberLong(4)
            },
            "optimeDurable" : {
                "ts" : Timestamp(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",
            "health" : 1,
            "state" : 7,
            "stateStr" : "ARBITER",
            "uptime" : 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" : Timestamp(1540601235, 1),
    "$clusterTime" : {
        "clusterTime" : Timestamp(1540601235, 1),
        "signature" : {
            "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
            "keyId" : NumberLong(0)
        }
    }
}
4

0 回答 0