用于将3个主节点连接到MySQL的ConnectionString [英] ConnectionString for connecting 3 master nodes to MySQL

查看:183
本文介绍了用于将3个主节点连接到MySQL的ConnectionString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

我正在开发一个.net项目,该项目可与EF6和MySQL DB一起使用.为了实现高可用性,我正在使用Galera群集,因此我有3个MySQL Master节点正在运行: master1 master2 master3 .

根据 connectionstring.com 我应该是能够使用以下连接字符串:

Server=master1, master2, master3;Database=myDataBase;
Uid=myUsername;Pwd=myPassword;

我已经尝试了上述方法,但无法正常工作...我已经看到该错误解释了多主机连接字符串不起作用.


问题

根据此链接,我可以使用JDBC连接字符串前面的mysql:loadbalance:.问题是我不知道我正在使用哪个MySQL连接器?我相信我已经为.net安装了标准/默认Nuget软件包( MySQL.Data MySQL.Data.EntityFramework ).知道上面的软件包附带哪个MySQL Connector吗?

任何想法如何使用MySQL连接器进行负载平衡/连接3个主节点?

解决方案

MySQL.Data不支持此功能.如您所见,存在多个错误报告(#81650 #88962 )指出了此问题,但三年来尚未解决.

在此处解释,还有一个替代的MySQL库, Pomelo.EntityFrameworkCore.MySql .)

一种解决方法是在您的三个Galera节点之前创建第4层负载均衡器. Galera提供了有关如何使用HAProxy 的文档.您的C#MySQL客户端将连接到HAProxy,并在Galera服务器之间实现负载平衡连接.

Backgroud

I am developing a .net project, which works with EF6 and MySQL DB. For High Availability, I am using Galera cluster, so I have 3 MySQL Master nodes up and running: master1, master2 and master3.

According to connectionstring.com I should be able to use the following connection string:

Server=master1, master2, master3;Database=myDataBase;
Uid=myUsername;Pwd=myPassword;

I have tried the above, and it does not work... I have seen this bug which explains multi-host connection string does not work.


Question

According to 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). Any idea which MySQL Connector come with the above packages?

Any idea how can I use MySQL connector to load balance/connect the 3 Master nodes?

解决方案

This isn't supported by MySQL.Data. As you observed, there are multiple bug reports (#81650, #88962) pointing out this problem, but it hasn't been fixed in three years.

As explained here, 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.)

A workaround would be to create a layer 4 load balancer in front of your three Galera nodes. Galera provides documentation on how to do this with HAProxy. Your C# MySQL client would connect to HAProxy, and it would load balance connections between your Galera servers.

这篇关于用于将3个主节点连接到MySQL的ConnectionString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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