大家好,又见面了,我是你们的朋友全栈君。
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.
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/158068.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...