connectionstring mysql,用于将3个主节点连接到MySQL的ConnectionString「建议收藏」

connectionstring mysql,用于将3个主节点连接到MySQL的ConnectionString「建议收藏」BackgroudIamdevelopinga.netproject,whichworkswithEF6andMySQLDB.ForHighAvailability,IamusingGaleracluster,soIhave3MySQLMasternodesupandrunning:master1,master2andmaster…

大家好,又见面了,我是你们的朋友全栈君。

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.

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/158068.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 2022Android SDK下载与安装

    2022Android SDK下载与安装一、下载sdk:https://www.androiddevtools.cn找个合适的位置解压双击“SDKManager.exe”,启动SDKManager安装工具我们可以通过有AndroidSDK的国内镜像服务器来下载安装,这里推荐几个:1、中科院开源协会镜像站地址:IPV4/IPV6:http://mirrors.opencas.ac.cn端口:802、北京化工大学镜像服务器地址:IPv4:http://ubuntu.buct.edu.cn/端口:80IPv

    2022年7月19日
    19
  • python中setattr用法_python中hasattr()、getattr()、setattr()函数的使用

    python中setattr用法_python中hasattr()、getattr()、setattr()函数的使用引言 在阅读源码时 有很多简写的形式 其中一个比较常用的就是 getattr 用来调用一个类中的变量或者方法 相关联的 hasattr getattr setattr 函数的使用也一并学习了一下 正文 1 hasattr object name 判断 object 对象中是否存在 name 属性 当然对于 python 的对象而言 属性包含变量和方法 有则返回 True 没有则返回 False 需要注

    2025年11月26日
    8
  • 快速排序(过程图解)

     假设我们现在对“6  1  27  9  3  4  510  8”这个10个数进行排序。首先在这个序列中随便找一个数作为基准数(不要被这个名词吓到了,就是一个用来参照的数,待会你就知道它用来做啥的了)。为了方便,就让第一个数6作为基准数吧。接下来,需要将这个序列中所有比基准数大的数放在6的右边,比基准数小的数放在6的左边,类似下面这种排列。    3  1  25  4  …

    2022年4月5日
    242
  • 人性的弱点

    1.与人相处的基本技巧永远不要尖锐地斥责别人斥责百害无一利,控制自己或则试着帮助他真诚地赞美他人激发他人的强烈需求2.如何让他人喜欢你真诚地关心他人微笑待人记住他人的名字善于倾听

    2021年12月30日
    29
  • HashMap原理<转>

    HashMap原理<转>

    2021年9月7日
    56
  • python常用模块大全_python常用第三方模块大全

    python常用模块大全_python常用第三方模块大全mathmath.ceil(a):用来返回≥a的最小整数math.floor(a):用来返回≤a的最大整数round(a[,b])如果没有参数b,只有a,round()作用是四舍五入如果

    2022年7月28日
    8

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号