简体   繁体   English

MongoDB副本集配置

[英]MongoDB replicaset configuration

Could you please tell me if this will cause any issues with failover? 您能否告诉我这是否会导致故障转移问题? For example, what would happen if host mongo2.local is down? 例如,如果主机mongo2.local关闭会发生什么? (assuming the original host and the arbiter go down and only 2 members are left). (假设原始主机和仲裁器停止运行,只剩下2个成员)。 Will the rest of the members be able to elect a new primary ever? 其他成员是否能够选出新的小学?

I know that there shouldn't be an arbiter here as it makes things worse but I wanted to know if a failover will occur in case of this setup and mongo2.local go down. 我知道这里不应该有仲裁者,因为这会使情况变得更糟,但是我想知道在这种设置和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
}

and: 和:

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
                }
        ]
}

If you have less than a majority of the votes in a replica set available, the replica set will not be able to elect or maintain a primary and the replica set will be unhealthy and will be read-only. 如果您在可用副本集中的票数少于大多数,则副本集将无法选择或维护主副本,副本集将不健康并且将是只读的。 Ergo, if you only have 2 of your 4 embers up, you will not have a primary. 因此,如果你的4个余烬中只有2个,那么你就不会有小学生。 No automatic failover will occur as there aren't enough votes for an election. 由于没有足够的选票投票,因此不会发生自动故障转移。

Don't have an even number of nodes in a replica set. 副本集中没有偶数个节点。 It increases the chances that there will be problems, just because there are more servers, without increasing the failure tolerance of the set. 它增加了出现问题的可能性,因为有更多的服务器,而不会增加集合的容错能力。 With 3 or 4 replica set members, 2 down servers will render the set unhealthy. 使用3个或4个副本集成员,2个向下服务器将使该集不健康。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM