使用 NHibernate 支持 AWS Aurora 故障转移功能的 .Net 应用程序驱动程序

编程入门 行业动态 更新时间:2024-10-19 14:27:28
本文介绍了使用 NHibernate 支持 AWS Aurora 故障转移功能的 .Net 应用程序驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在将我的数据库从 MSSQL 迁移到 Aurora (MYSQL).该应用程序使用 和 NHibernate.我们为 MYSQLMySql.Data"尝试了 Nhibernate 驱动程序,它适用于所有用例,但故障转移.当发生故障转移时,连接不会重置,它会不断尝试从写入器集群连接到旧 IP,因此所有写入调用都失败,但异常MySQL 服务器正在使用 --read--only 选项运行,因此它无法执行此语句".这只有在 Web 服务器上执行 IISRESET 后才能解决.

I am migrating my Database from MSSQL to Aurora(MYSQL). The application is using and NHibernate. We tried the Nhibernate driver for MYSQL "MySql.Data" and it works fine for all use cases but failover. When a failover happens, the connection is not reset and it keeps trying to connect to the old IP from the writer cluster and so all the write call fails with the exception "The MySQL server is running with the --read-- only option so it cannot execute this statement". This only gets resolved after doing an IISRESET on the web servers.

我知道对于 Java,MariaDB 连接器能够处理这个用例.是否有任何类似的驱动程序可用于 应用程序?处理此类用例的最佳做法是什么?

I know that for java, the MariaDB connector is able to take care of this use case. Is there any similar driver available for applications? What is the best practice to handle such use case?

推荐答案

MariaDB java 连接器有 Aurora 的特定实现. 没有我所知道的.仍然是使用集群 DNS 的正常解决方案:Aurora 提供不同的 DNS 链接:

MariaDB java connector has a specific implementation for Aurora. There is none that i know for . Still the normal solution is using cluster DNS : Aurora provide different DNS link:

  • 每个实例一个
  • 集群端点(如 xxx.cluster-yyy.zzz.rds.amazonaws)
  • 读取器端点(负载平衡)(如 xxx.cluster-ro-yyy.zzz.rds.amazonaws)

使用集群端点,您正在使用当前的编写器实例.当发生故障转移时,此 DNS 将指向新的主服务器,但此更改需要一些时间(<60 秒),因此在此间隔期间,您可能最终指向以前的主服务器,如果可用,现在将是从服务器指向到一个新的贴纸.

Using the cluster endpoint, you are using the current writer instance. When there is a failover, this DNS will point to the new master, but this change take some time (<60s), so during that interval you may end up pointing to the previous master, that if available will be now a slave pointing to a new paster.

最好的解决方案是查询show global variables like 'innodb_read_only'"检查结果是否为OFF以验证连接.

The best solution is to query "show global variables like 'innodb_read_only'" checking that result is OFF to validate connection.

更多推荐

使用 NHibernate 支持 AWS Aurora 故障转移功能的 .Net 应用程序驱动程序

本文发布于:2023-11-07 23:01:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1567678.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:驱动程序   应用程序   故障   功能   AWS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!