使用 NHibernate 支持 AWS Aurora 故障转移功能的 .Net 应用程序驱动程序 [英] Driver for .Net Application using NHibernate to support failover functionality of AWS Aurora

查看:34
本文介绍了使用 NHibernate 支持 AWS Aurora 故障转移功能的 .Net 应用程序驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am migrating my Database from MSSQL to Aurora(MYSQL). The application is using .net 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 连接器能够处理这个用例.是否有任何类似的驱动程序可用于 .net 应用程序?处理此类用例的最佳做法是什么?

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

推荐答案

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

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

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

使用集群端点,您正在使用当前的编写器实例.当发生故障转移时,此 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 应用程序驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆