用于将 3 个主节点连接到 MySQL 的 ConnectionString
ConnectionString for connecting 3 master nodes to MySQL
背景
我正在开发一个 .net 项目,它与 EF6 和 MySQL 数据库一起工作。对于高可用性,我使用的是 Galera 集群,所以我有 3 个 MySQL 主节点和 运行:master1,master2 和 master3.
根据 connectionstring.com 我应该可以使用以下连接字符串:
Server=master1, master2, master3;Database=myDataBase;
Uid=myUsername;Pwd=myPassword;
我已经尝试了上面的方法,但它不起作用...我看到 this bug 解释了多主机连接字符串不起作用。
问题
根据this link I can use mysql:loadbalance:
in front of my JDBC connection string. The problem is I don't know which MySQL Connector am I using? I believe I have installed the Standard/Default Nuget Packages for .net (MySQL.Data and MySQL.Data.EntityFramework)。知道上面的软件包附带了哪个 MySQL 连接器吗?
知道如何使用 MySQL 连接器加载 balance/connect 3 个主节点吗?
MySQL.Data 不支持此功能。正如您所观察到的,有多个错误报告 (#81650, #88962) 指出了这个问题,但它已经三年没有得到修复。
如, there is an alternative MySQL library, MySqlConnector, that does support this connection string syntax. Unfortunately, there is no EF6 library available for it. (There is an EF.Core package, Pomelo.EntityFrameworkCore.MySql.)
解决方法是在您的三个 Galera 节点前创建第 4 层负载均衡器。 Galera 提供关于 how to do this with HAProxy 的文档。您的 C# MySQL 客户端将连接到 HAProxy,它会在您的 Galera 服务器之间对连接进行负载平衡。
此错误已在 Connector/NET version 8.0.19
中修复
在此处查看发行说明:https://insidemysql.com/
背景
我正在开发一个 .net 项目,它与 EF6 和 MySQL 数据库一起工作。对于高可用性,我使用的是 Galera 集群,所以我有 3 个 MySQL 主节点和 运行:master1,master2 和 master3.
根据 connectionstring.com 我应该可以使用以下连接字符串:
Server=master1, master2, master3;Database=myDataBase;
Uid=myUsername;Pwd=myPassword;
我已经尝试了上面的方法,但它不起作用...我看到 this bug 解释了多主机连接字符串不起作用。
问题
根据this link I can use mysql:loadbalance:
in front of my JDBC connection string. The problem is I don't know which MySQL Connector am I using? I believe I have installed the Standard/Default Nuget Packages for .net (MySQL.Data and MySQL.Data.EntityFramework)。知道上面的软件包附带了哪个 MySQL 连接器吗?
知道如何使用 MySQL 连接器加载 balance/connect 3 个主节点吗?
MySQL.Data 不支持此功能。正如您所观察到的,有多个错误报告 (#81650, #88962) 指出了这个问题,但它已经三年没有得到修复。
如
解决方法是在您的三个 Galera 节点前创建第 4 层负载均衡器。 Galera 提供关于 how to do this with HAProxy 的文档。您的 C# MySQL 客户端将连接到 HAProxy,它会在您的 Galera 服务器之间对连接进行负载平衡。
此错误已在 Connector/NET version 8.0.19
中修复在此处查看发行说明:https://insidemysql.com/