数据库集群和负载均衡

发布于 2024-07-27 17:38:57 字数 78 浏览 4 评论 0原文

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

森末i 2024-08-03 17:38:57

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

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

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

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

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

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

    缺点是容错能力较差,如果主节点死亡,从节点不会再发生任何变化。

    优点是它比多主服务器更容易实现,并且通常保留 ACID 属性。

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

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.

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.

又怨 2024-08-03 17:38:57

从 SQL Server 的角度来看:

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

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

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

From SQL Server point of view:

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.

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).

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.

醉酒的小男人 2024-08-03 17:38:57

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

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

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.

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.

如何视而不见 2024-08-03 17:38:57

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

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

现在说说区别:负载均衡只是集群可以实现的结果之一,其他的还包括高可用性、可扩展性和容错性。

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).

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文