MongoDB replicaset配置

时间:2015-02-12 09:27:03

标签: mongodb

您能否告诉我这是否会导致故障转移问题?例如,如果主机mongo2.local关闭会发生什么? (假设原始主机和仲裁器停止运行,只剩下2个成员)。其他成员是否能够选出新的小学?

我知道这里不应该是仲裁者,因为它会使事情变得更糟但我想知道在这种设置情况下是否会发生故障转移并且mongo2.local会失效。

mongo:ARBITER> rs.status()
{
        "set" : "mongo",
        "date" : ISODate("2015-02-12T09:00:08Z"),
        "myState" : 7,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "mongo1.local:27017",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 2572473,
                        "optime" : Timestamp(1423731603, 4),
                        "optimeDate" : ISODate("2015-02-12T09:00:03Z"),
                        "lastHeartbeat" : ISODate("2015-02-12T09:00:07Z"),
                        "lastHeartbeatRecv" : ISODate("2015-02-12T09:00:07Z"),
                        "pingMs" : 0,
                        "syncingTo" : "mongo2.local:27017"
                },
                {
                        "_id" : 1,
                        "name" : "mongo2.local:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 12148099,
                        "optime" : Timestamp(1423731603, 4),
                        "optimeDate" : ISODate("2015-02-12T09:00:03Z"),
                        "lastHeartbeat" : ISODate("2015-02-12T09:00:08Z"),
                        "lastHeartbeatRecv" : ISODate("2015-02-12T09:00:08Z"),
                        "pingMs" : 0,
                        "electionTime" : Timestamp(1423711411, 1),
                        "electionDate" : ISODate("2015-02-12T03:23:31Z")
                },
                {
                        "_id" : 2,
                        "name" : "mongo3.local:27017",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 5474488,
                        "optime" : Timestamp(1423731603, 4),
                        "optimeDate" : ISODate("2015-02-12T09:00:03Z"),
                        "lastHeartbeat" : ISODate("2015-02-12T09:00:07Z"),
                        "lastHeartbeatRecv" : ISODate("2015-02-12T09:00:08Z"),
                        "pingMs" : 139,
                        "syncingTo" : "mongo2.local:27017"
                },
                {
                        "_id" : 3,
                        "name" : "mongo2.local:27020",
                        "health" : 1,
                        "state" : 7,
                        "stateStr" : "ARBITER",
                        "uptime" : 12148101,
                        "self" : true
                }
        ],
        "ok" : 1
}

mongo:ARBITER> rs.config()
{
        "_id" : "mongo",
        "version" : 5,
        "members" : [
                {
                        "_id" : 0,
                        "host" : "mongo1.local:27017",
                        "priority" : 0.5
                },
                {
                        "_id" : 1,
                        "host" : "mongo2.local:27017"
                },
                {
                        "_id" : 2,
                        "host" : "mongo3.local:27017",
                        "priority" : 0.5
                },
                {
                        "_id" : 3,
                        "host" : "mongo2.local:27020",
                        "arbiterOnly" : true
                }
        ]
}

1 个答案:

答案 0 :(得分:0)

如果您在可用副本集中的票数少于大多数,则副本集将无法选择或维护主副本,副本集将不健康并且将是只读的。因此,如果你的4个余烬中只有2个,那么你就不会有小学生。由于没有足够的选票投票,因此不会发生自动故障转移。

副本集中没有偶数个节点。它增加了出现问题的可能性,因为有更多的服务器,而不会增加集合的容错能力。对于3个或4个副本集成员,2个向下服务器将使该集不健康。