配置Apache Cassandra进行灾难恢复 [英] Configuring Apache Cassandra for Disaster Recovery

查看:130
本文介绍了配置Apache Cassandra进行灾难恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何配置Apache Cassandra以允许灾难恢复,从而允许两个数据中心之一出现故障?

How do you configure Apache Cassandra to allow for disaster recovery, to allow for one of two data-centres to fail?

DataStax文档介绍了使用复制策略确保至少一个复制写入每个数据 - 中心。但我不认为灾难发生后如何帮助。如果切换到其余的数据中心,所有的写入都将失败,因为这些写入将无法复制到其他数据中心。

The DataStax documentation talks about using a replication strategy that ensures at least one replication is written to each of your two data-centres. But I don't see how that helps once the disaster has actually happened. If you switch to the remaining data-centre, all your writes will fail because those writes will not be able to replicate to the other data-centre.

我想你会希望您的软件以两种模式运行:正常模式,写入必须在两个数据中心和灾难模式之间复制,不需要。但是改变复制策略似乎是不可能的。

I guess you would want your software to operate in two modes: normal mode, for which writes must replicate across both data-centres, and disaster mode, for which they need not. But changing replication strategy does not seem possible.

我真正想要的是两个数据中心过度配置,在正常操作期间使用两个数据中心的资源,但是当只有一个数据中心运行时,只使用一个剩余数据中心的资源(性能降低)。

What I really want is two data-centres that are over provisioned, and during normal operations use the resources of both data-centres, but use the resources of only the one remaining data-centre (with reduced performance) when only one data-centre is functioning.

推荐答案

诀窍是改变通过API为写入给出的一致性设置,而不是改变复制因素。在灾难期间,当只有一个数据中心可用时,使用 LOCAL_QUORUM 设置进行写入。在正常操作期间,使用 EACH_QUORUM 可确保两个数据中心都有数据副本。读取可以始终使用 LOCAL_QUORUM

The trick is to vary the consistency setting given through the API for writes, instead of varying the replication factor. Use the LOCAL_QUORUM setting for writes during a disaster, when only one data-centre is available. During normal operation use EACH_QUORUM to ensure both data-centres have a copy of the data. Reads can use LOCAL_QUORUM all the time.

这里是多个数据中心,以及概念上相关的灾难恢复(0.7)

Here is a summary of the Datastax documentation for multiple data centers and the older but still conceptionally relevant disaster recovery (0.7).

做一个配方,满足你的需求一致性 LOCAL_QUORUM EACH_QUORUM

Make a recipe to suite your needs with the two consistencies LOCAL_QUORUM and EACH_QUORUM.


这里,本地表示单个数据中心的本地,而每个表示在每个数据中心中严格保持相同级别的一致性。

Here, "local" means local to a single data center, while "each" means consistency is strictly maintained at the same level in each data center.

假设您有2个数据中心,一个严重用于灾难恢复,那么您可以将复制因子设置为...

Suppose you have 2 datacenters, one used strictly for disaster recovery then you could set the replication factor to...


<

现在,您的数据有多么关键实际写入灾难恢复节点,则可以使用EACH_QUORUM或LOCAL_QUORUM。假设您正在使用复制放置策略 NetworkTopologyStrategy(NTS)

Now depending how critical it is that your data is actually written to the disaster recovery nodes, you can either use EACH_QUORUM or LOCAL_QUORUM. Assuming you are using a replication placement strategy NetworkTopologyStrategy (NTS),

LOCAL_QUORUM 写入操作只会延迟客户端本地写入DC1并异步写入DC2中的恢复节点。

LOCAL_QUORUM on writes will only delay the client to write locally to the DC1 and asynchronously write to your recovery node(s) in DC2.

EACH_QUORUM 将确保所有数据都被复制,但会延迟写入,直到两个DC都确认成功操作。

EACH_QUORUM will ensure that all data is replicated but will delay writes until both DCs confirm successful operations.

对于读取,最好只是请使用LOCAL_QUORUM避免数据中心间延迟

For reads it's likely best to just use LOCAL_QUORUM to avoid inter-data center latency.

这种方法有抓获!如果您选择在您的写入中使用EACH_QUORUM,则增加了潜在的故障点(DC2已关闭,DC1-DC2链路已关闭,DC1仲裁将无法满足)。

There are catches to this approach! If you choose to use EACH_QUORUM on your writes you increase the potential failure points (DC2 is down, DC1-DC2 link is down, DC1 quorum can't be met).

奖金是一旦你的DC1下来,你有一个有效的DC2灾难恢复。另外请注意,在第二个链接,它谈到自定义snitch设置正确路由您的IP。

The bonus is once your DC1 goes down, you have a valid DC2 disaster recovery. Also note in the 2nd link it talks about custom snitch settings for routing your IPs properly.

这篇关于配置Apache Cassandra进行灾难恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆