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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • net MVC 3.0 1

    net MVC 3.0 1首先,我们为什么要用MVC呢,因为比起

    2022年7月27日
    6
  • mysql的case when语法_sql基本语句大全

    mysql的case when语法_sql基本语句大全介绍mysql数据库中casewhen语句的用法,首先介绍casewhen语句的基础知识,然后提供了相关例子。(1)mysql数据库中CASEWHEN语句。casewhen语句,用于计算条件列表并返回多个可能结果表达式之一。CASE具有两种格式:简单CASE函数将某个表达式与一组简单表达式进行比较以确定结果。CASE搜索函数计算一组布尔表达式以确定结果。两种格式都支持…

    2025年9月18日
    9
  • nc的使用_p什么nc什么l

    nc的使用_p什么nc什么l什么是ncnc是netcat的简写,有着网络界的瑞士军刀美誉。因为它短小精悍、功能实用,被设计为一个简单、可靠的网络工具nc的作用(1)实现任意TCP/UDP端口的侦听,nc可以作为server以TCP或UDP方式侦听指定端口(2)端口的扫描,nc可以作为client发起TCP或UDP连接(3)机器之间传输文件(4)机器之间网络测速…

    2025年6月11日
    2
  • MFC CCriticalSection 关键段

    MFC CCriticalSection 关键段和其他同步对象不同,除非有需要以外,关键区域工作在用户模式下。若一个线程想运行一个封装在关键区域中的代码,它首先做一个旋转封锁,然后等待特定的时间,它进入内核模式去等待关键区域。实际上,关键区域持有一个旋转计数器和一个信号量,前者用于用户模式的等待,后者用于内核模式的等待(休眠态)。在Win32API中,有一个CRITICAL_SECTION结构体表示关键区域对象。在MFC中,有一个类CCri

    2022年7月21日
    12
  • 运维利器之–ipmitool

    运维利器之–ipmitoolIpmitool 对搞运维的哥们儿来说是一个很不错的管理工具 既支持本地操作也支持远端操作 能够不依赖服务器的 CPU 内存 存储 电源等独立工作 是一种廉价远程管理方案 借用一下官方的介绍 Theservicepr orBaseboardM BMC isthebrainbe

    2025年11月1日
    3
  • 如何安装Pycharm_pycharm安装教程2020

    如何安装Pycharm_pycharm安装教程2020安装方法:1、安装配置好Python环境;2、从官网下载pycharm安装程序;3、直接双击下载好的exe文件,进入安装向导界面,按照指示一步步操作;4、点击Install进行安装,等待安装完成后,点击Finish结束安装即可。本教程操作环境:windows7系统、Python3.5.2版本、DellG3电脑。首先我们来安装python1、首先进入网站下载:点击打开链接(或自己输入网址http…

    2022年8月25日
    6

发表回复

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

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