主备数据中心集群的Cassandra一致性级别策略
Cassandra consistency level strategy for active-standby datacenter cluster
我们使用 Cassandra 3.9 作为后端。我们希望在 主备模式 下为我们的产品支持 geo-diverse,这样当主用数据中心发生灾难时,我们希望将所有请求切换到备用数据中心。我们计划将数据中心和 "LOCAL_QUORUM" 的复制因子都设置为 3 作为仅活动数据中心的写入一致性级别。
是否可以仅针对活动数据中心设置"LOCAL_QUORUM"。
如果按照上面的方法,我们担心数据会不会
在备用数据中心同步,因为所有写入请求都会发生
异步地。有没有办法识别数据已经更新
在备用数据中心成功。
请建议我们更好地strategy/approach处理活动备用数据中心。
您的问题:
1) LOCAL_QUORUM 意味着您的读取或写入只有在协调器所在的数据中心达到 QUORUM 时才会成功。所以是的,如果您定义数据中心并使用类似
cluster.builder()
.withLoadBalancingPolicy(DCAwareRoundRobinPolicy.builder()
.withLocalDc("DC1")
.withUsedHostsPerRemoteDc(3).build())
摘自此处 - 您在 DC1 中有 LOCAL_QUORUM。
别管你使用 LOCAL_QUORUM 复制将继续复制到所有数据中心,并尝试维护为每个数据中心定义的复制因子,在你的情况下每个数据中心 3 个。
该示例的好处 - 在数据中心丢失的情况下定义的行为:
If usedHostsPerRemoteDc > 0, then if for a query no host in the local
datacenter can be reached and if the consistency level of the query is
not LOCAL_ONE or LOCAL_QUORUM, then up to usedHostsPerRemoteDc hosts
per remote datacenter will be tried by the policy as a fallback. By
default, no remote host will be used for LOCAL_ONE and LOCAL_QUORUM,
since this would change the meaning of the consistency level, somewhat
breaking the consistency contract (this can be overridden with
allowRemoteDCsForLocalConsistencyLevel()).
2) 如上所述,复制始终保持配置。无论如何,您将需要一些监控来检查是否一切正常(所有节点都启动、提示、日志等)。
如果您真的担心所有数据中心都具有一致的数据,您可以使用 EACH_QUORUM,当每个数据中心达到法定人数时,只有 returns 成功。但这可能会严重影响延迟。
如果您的网络连接是 "good enough" 并且您进行了滚动维修,那么 LOCAL_QUORUM 应该没问题。
另请参阅:http://docs.datastax.com/en/cassandra/2.1/cassandra/dml/dml_config_consistency_c.html
我们使用 Cassandra 3.9 作为后端。我们希望在 主备模式 下为我们的产品支持 geo-diverse,这样当主用数据中心发生灾难时,我们希望将所有请求切换到备用数据中心。我们计划将数据中心和 "LOCAL_QUORUM" 的复制因子都设置为 3 作为仅活动数据中心的写入一致性级别。
是否可以仅针对活动数据中心设置"LOCAL_QUORUM"。
如果按照上面的方法,我们担心数据会不会 在备用数据中心同步,因为所有写入请求都会发生 异步地。有没有办法识别数据已经更新 在备用数据中心成功。
请建议我们更好地strategy/approach处理活动备用数据中心。
您的问题:
1) LOCAL_QUORUM 意味着您的读取或写入只有在协调器所在的数据中心达到 QUORUM 时才会成功。所以是的,如果您定义数据中心并使用类似
cluster.builder()
.withLoadBalancingPolicy(DCAwareRoundRobinPolicy.builder()
.withLocalDc("DC1")
.withUsedHostsPerRemoteDc(3).build())
摘自此处
别管你使用 LOCAL_QUORUM 复制将继续复制到所有数据中心,并尝试维护为每个数据中心定义的复制因子,在你的情况下每个数据中心 3 个。
该示例的好处 - 在数据中心丢失的情况下定义的行为:
If usedHostsPerRemoteDc > 0, then if for a query no host in the local datacenter can be reached and if the consistency level of the query is not LOCAL_ONE or LOCAL_QUORUM, then up to usedHostsPerRemoteDc hosts per remote datacenter will be tried by the policy as a fallback. By default, no remote host will be used for LOCAL_ONE and LOCAL_QUORUM, since this would change the meaning of the consistency level, somewhat breaking the consistency contract (this can be overridden with allowRemoteDCsForLocalConsistencyLevel()).
2) 如上所述,复制始终保持配置。无论如何,您将需要一些监控来检查是否一切正常(所有节点都启动、提示、日志等)。
如果您真的担心所有数据中心都具有一致的数据,您可以使用 EACH_QUORUM,当每个数据中心达到法定人数时,只有 returns 成功。但这可能会严重影响延迟。
如果您的网络连接是 "good enough" 并且您进行了滚动维修,那么 LOCAL_QUORUM 应该没问题。
另请参阅:http://docs.datastax.com/en/cassandra/2.1/cassandra/dml/dml_config_consistency_c.html