connectionstring mysql,用于将3个主节点连接到MySQL的ConnectionString

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值