database 数据库集群和负载均衡

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1163216/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 07:24:47  来源:igfitidea点击:

Database cluster and load balancing

databaseload-balancingcluster-computingdatabase-agnostic

提问by Malik Daud Ahmad Khokhar

What is database clustering? If you allow the same database to be on 2 different servers how do they keep the data between synchronized. And how does this differ from load balancing from a database server perspective?

什么是数据库集群?如果您允许相同的数据库位于 2 个不同的服务器上,它们如何保持数据同步。从数据库服务器的角度来看,这与负载平衡有何不同?

回答by Vinko Vrsalovic

Database clustering is a bit of an ambiguous term, some vendors consider a cluster having two or more servers share the same storage, some others call a cluster a set of replicated servers.

数据库集群是一个有点含糊的术语,一些供应商认为集群有两个或更多服务器共享相同的存储,其他一些供应商将集群称为一组复制服务器。

Replication defines the method by which a set of servers remain synchronized without having to share the storage being able to be geographically disperse, there are two main ways of going about it:

复制定义了一组服务器保持同步而不必共享能够在地理上分散的存储的方法,主要有两种方法:

  • master-master (or multi-master) replication: Any server can update the database. It is usually taken care of by a different module within the database (or a whole different software running on top of them in some cases).

    Downside is that it is very hard to do well, and some systems lose ACID properties when in this mode of replication.

    Upside is that it is flexible and you can support the failure of any server while still having the database updated.

  • master-slave replication: There is only a single copy of authoritative data, which is the pushed to the slave servers.

    Downside is that it is less fault tolerant, if the master dies, there are no further changes in the slaves.

    Upside is that it is easier to do than multi-master and it usually preserve ACID properties.

  • 主-主(或多主)复制:任何服务器都可以更新数据库。它通常由数据库中的不同模块(或在某些情况下运行在它们之上的完全不同的软件)处理。

    缺点是很难做好,有些系统在这种复制模式下会丢失 ACID 属性。

    好处是它很灵活,您可以在仍然更新数据库的同时支持任何服务器的故障。

  • 主从复制:权威数据只有一个副本,即推送到从服务器。

    缺点是容错性较差,如果 master 死了,slaves 就没有进一步的变化。

    好处是它比多主机更容易做,并且它通常保留 ACID 属性。

Load balancing is a different concept, it consists distributing the queries sent to those servers so the load is as evenly distributed as possible. It is usually done at the application layer (or with a connection pool). The only direct relation between replication and load balancing is that you need some replication to be able to load balance, else you'd have a single server.

负载平衡是一个不同的概念,它包括分配发送到这些服务器的查询,以便尽可能均匀地分配负载。它通常在应用层(或使用连接池)完成。复制和负载平衡之间唯一的直接关系是您需要一些复制才能进行负载平衡,否则您将只有一台服务器。

回答by Jimmy Chandra

From SQL Server point of view:

从 SQL Server 的角度来看:

Clustering will give you an active - passive configuration. Meaning in a 2 node cluster, one of them will be the active (serving) and the other one will be passive (waiting to take over when the active node fails). It's a high availability from hardware point of view.

集群将为您提供主动-被动配置。这意味着在 2 节点集群中,其中一个将是主动的(服务),另一个将是被动的(当主动节点出现故障时等待接管)。从硬件的角度来看,这是一种高可用性。

You can have an active-active cluster, but it will require multiple instances of SQL Server running on each node. (i.e. Instance 1 on Node A failing over to Instance 2 on Node B, and instance 1 on Node B failing over to instance 2 on Node A).

您可以拥有一个主动-主动群集,但它需要在每个节点上运行多个 SQL Server 实例。(即节点 A 上的实例 1 故障转移到节点 B 上的实例 2,节点 B 上的实例 1 故障转移到节点 A 上的实例 2)。

Load balancing (at least from SQL Server point of view) does not exists (at least in the same sense of web server load balancing). You can't balance load that way. However, you can split your application to run on some database on server 1 and also run on some database on server 2, etc. This is the primary mean of "load balancing" in SQL world.

负载平衡(至少从 SQL Server 的角度来看)不存在(至少在 Web 服务器负载平衡的意义上)。您无法以这种方式平衡负载。但是,您可以将应用程序拆分为在服务器 1 上的某个数据库上运行,也可以在服务器 2 上的某个数据库上运行,等等。这是 SQL 世界中“负载平衡”的主要方法。

回答by SqlRyan

Clustering uses shared storage of some kind (a drive cage or a SAN, for example), and puts two database front-ends on it. The front end servers share an IP address and cluster network name that clients use to connect, and they decide between themselves who is currently in charge of serving client requests.

集群使用某种共享存储(例如驱动器笼或 SAN),并在其上放置两个数据库前端。前端服务器共享客户端用于连接的 IP 地址和集群网络名称,并且它们自己决定当前负责为客户端请求提供服务的人。

If you're asking about a particular database server, add that to your question and we can add details on their implementation, but at its core, that's what clustering is.

如果您询问特定的数据库服务器,请将其添加到您的问题中,我们可以添加有关其实现的详细信息,但在其核心,这就是集群。

回答by Puneet Misra

Database Clustering is actually a mode of synchronous replication between two or possibly more nodes with an added functionality of fault tolerance added to your system, and that too in a shared nothing architecture. By shared nothing it means that the individual nodes actually don't share any physical resources like disk or memory.

数据库集群实际上是两个或更多节点之间的同步复制模式,并为您的系统添加了容错功能,并且在无共享架构中也是如此。不共享意味着各个节点实际上不共享任何物理资源,如磁盘或内存。

As far as keeping the data synchronized is concerned, there is a management server to which all the data nodes are connected along with the SQL node to achieve this(talking specifically about MySQL).

就保持数据同步而言,有一个管理服务器,所有数据节点和SQL节点都连接到管理服务器上来实现这一点(具体说一下MySQL)。

Now about the differences: load balancing is just one result that could be achieved through clustering, the others include high availability, scalability and fault tolerance.

现在谈谈差异:负载均衡只是通过集群可以实现的一个结果,其他包括高可用性、可扩展性和容错性。