简体   繁体   English

Mongodb架构和具有两个数据中心的故障转移

[英]Mongodb architecture and failover with two data centres

I'm trying to figure out whether there is a way to seamlessly failover a mongo replicaset where most of the mongodb nodes live in the primary data centre. 我试图弄清楚是否有一种方法可以无缝地对mongo副本集进行故障转移,而大多数mongodb节点都位于主数据中心中。 My current limitation is 2 data centres and third datacentre is out of the question. 我当前的限制是2个数据中心,第三个数据中心是不可能的。 The issue I have is that if data centre 1 goes down, the secondary node in data centre 2 will not be promoted to primary without manual intervention. 我的问题是,如果数据中心1发生故障,那么在没有人工干预的情况下,数据中心2中的辅助节点将不会升级为主节点。

Data centre 1 (Primary): Mongo Node (Primary) Mongo Node (Arbiter) 数据中心1(主):Mongo节点(主)Mongo节点(仲裁器)

Data centre 2 (Secondary): Mongo Node (Secondary) 数据中心2(中学):Mongo Node(中学)

I've looked at mongodb whitepapers but they state manual intervention is required to make the mongodb instance in dc2 primary if dc1 is lost. 我看过mongodb白皮书,但它们指出,如果dc1丢失,则需要手动干预才能在dc2主数据库中创建mongodb实例。

My question is whether there is an architecture out there or configuration that will make it possible to lose data centre 1 and still have the ability to have a data centre 2 takeover with write enabled without manual intervention/reconfiguration. 我的问题是,是否存在一种架构或配置,该架构或配置将使其有可能丢失数据中心1,并且仍然具有在无需手动干预/重新配置的情况下启用写操作的数据中心2接管能力。 Is this possible without going down a 3 data centre architecture path. 在不采用3数据中心体系结构的情况下是否可以做到这一点。 Is it possible to keep two 3 member replica sets at each site synchronised and potentially do the failover at a network level for the connecting applications? 是否可以使每个站点上的两个3个成员副本集保持同步,并可能对连接的应用程序进行网络级别的故障转移?

Thanks. 谢谢。

If you go with 2 data centers to me easiest solution is to cover only fail in Primary. 如果对我来说有2个数据中心,最简单的解决方案是仅覆盖Primary中的失败。 Good news is if Slave is dead - you only need to wait. 好消息是,如果Slave已死-您只需要等待即可。

If access to Primary fails you need to callback procedure that will force Slave to Primary. 如果无法访问Primary,则需要回调将Slave强制为Primary的过程。 This switch will cause downtime in your application if you don't spent more time to create a gateway that will buffer queries and waits for callback from the switch. 如果您不花更多时间创建网关来缓冲查询并等待来自交换机的回调,则此开关将导致应用程序停机。 In that way you will have only slowness with increase timeout. 这样,随着超时的增加,您将只会变得缓慢。

After Primary is live again you need to connect back to it (because your Slave node is not reliable) - this will cause again downtime- you need another process that checks if Primary is alive (from data center 2) and if it is trigger event and proceed with callback. 在主服务器再次上线之后,您需要重新连接到它(因为您的从节点不可靠)-这将再次导致停机-您需要另一个过程来检查主数据库是否处于活动状态(来自数据中心2)以及是否是触发事件并继续进行回调。

Manual intervention to force Slave as Primary can be wrapped to script. 可以强制将Slave设置为Primary的手动干预可以包装到脚本中。

To me here best solution is to go with 3rd data center where arbiter will stay. 对我而言,最好的解决方案是使用第三个数据中心,仲裁器将保留在那里。 The effort to skip that and put application logic there is not worthy. 跳过这一点并将应用程序逻辑放在那的努力是不值得的。 Automatic failover in Mongo works very well and its reliable. Mongo中的自动故障转移非常有效且可靠。 You may have lots of problems if you go with application logic to achieve that with 2 data centers ... I rather go with their recommendation. 如果您使用应用程序逻辑通过2个数据中心来实现这一目标,则可能会遇到很多问题。我宁愿接受他们的建议。

First, as you have noticed, you cannot do automatic fail over with only two nodes. 首先,您已经注意到,您不能仅使用两个节点进行自动故障转移。 Second, money is not real issue when you think that "third" data center. 其次,当您认为“第三”数据中心时,金钱并不是真正的问题。 You may ask why or "how so"? 您可能会问为什么或“怎么做”? You need arbiter, as you know. 如您所知,您需要仲裁人。 Arbiter don't need resources really, any small Linux machine will do fine. 仲裁器确实不需要资源,任何小型Linux机器都可以。 Small VPS machines don't cost that much. 小型VPS机器不需要花费那么多。 Here you can find machine 1 x 2.40 GHz, 512 MB, 20 GB with only 1,24€/month. 在这里您可以找到机器1 x 2.40 GHz,512 MB,20 GB ,每月仅需1.24€。 From here you get beefier machine with 1.99€/month. 从这里您将获得每月1.99欧元的更强大的机器。

Actually both those places could run quite big mongodb with those "tiny" machines. 实际上,这两个地方都可以使用这些“微型”机器运行相当大的mongodb。

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

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