简体   繁体   English

Grails支持处理数据源故障

[英]Grails Support to Handle Datasource Failure

I am looking for a solution for automatic database failover in grails application. 我正在寻找grails应用程序中的自动数据库故障转移的解决方案。 I have two databases which reside on two different sites connected over WAN. 我有两个数据库,它们位于通过WAN连接的两个不同站点上。 On Site A, we have Database 01 which is primary database for application on the same site on which database resides which is Application 1 while it would be treated as a secondary database for application on other site which is Application 2 and vice versa. 在站点A上,我们有数据库01,它是数据库所在的同一站点上的应用程序的主数据库,它是应用程序1,而它将被视为应用程序2的其他站点上的应用程序的辅助数据库,反之亦然。

Please refer to the image below for more details: 有关详细信息,请参阅下图:

期望的数据库复制和故障转移设计

So, according to the design described above: 所以,根据上面描述的设计:

  • Application deployed on Site A should use database at Site A primarily 站点A上部署的应用程序应主要使用站点A的数据库
  • If somehow database at Site A is not accessible, then application deployed at Site A should use database at Site B (as a secondary database) 如果站点A的某个数据库无法访问,则站点A部署的应用程序应使用站点B的数据库(作为辅助数据库)
  • Once Database at Site A comes up, the application deployed at Site A should again start using the database at Site A (as a primary database) 一旦站点A上的数据库出现,站点A上部署的应用程序应该再次开始使用站点A的数据库(作为主数据库)

In the same way, it should work for application at Site B. For application at Site B, Database at Site B should be used primarily (as a primary database) and database at site B (as a secondary database). 同样,它应该适用于站点B的应用程序。对于站点B的应用程序,站点B的数据库应主要(作为主数据库)和站点B的数据库(作为辅助数据库)使用。

Note: When database at corresponding site comes up, application at that site (on which it is deployed) again should start using the database to avoid unnecessary communication over the WAN. 注意:当相应站点上的数据库出现时,该站点(部署它)的应用程序应该再次开始使用数据库,以避免通过WAN进行不必要的通信。

Do grails provide any such support that we may specify two data sources one as a primary and another one as a secondary (that would just be used in case primary isn't accessible.)? grails是否提供任何此类支持,我们可以指定两个数据源,一个作为主要数据源,另一个作为辅助数据源(仅在主要数据库无法访问的情况下使用)。

And If there is no such mechanism, then we need to continually check if the primary data source is up & running otherwise switch to the secondary data source which seems inappropriate at all and don't want to go for this option. 如果没有这样的机制,那么我们需要不断检查主数据源是否正常运行,否则切换到辅助数据源,这似乎是不合适的,并且不想使用此选项。

The real answer is not to have your code of any sort handle this, but to implement a load balancer which will route traffic accordingly. 真正的答案是不要让你的任何类型的代码处理这个,而是实现一个负载平衡器,它将相应地路由流量。 While you could do this in your own code (in theory), whatever solution you come up with will fall far short of what an actual load balancer is capable of regarding fail overs. 虽然你可以在你自己的代码(理论上)中做到这一点,但是你提出的任何解决方案都远远不能达到实际负载平衡器能够实现的故障转移。

To answer your question, Grails does not have anything that will address this concern. 为了回答你的问题,Grails没有任何解决这个问题的方法。 This concern should be addressed outside of your application and instead be part of your network/infrastructure topology design/implementation. 应该在应用程序之外解决此问题,而应将其作为网络/基础架构拓扑设计/实现的一部分。

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

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