2021年1月22日星期五

Micro-service with Spring Cassandra doesn't failover to remote cluster

I setup two data centers (DC1, DC2) with 3 nodes each. consistency-level is local_quorum and serial-consistency-level is LOCAL_SERIAL. The local-datacenter is DC1. The micro-service doesn't failover to DC2 automatically when there is only one node alive in the local data center, instead it keeps complaining "Not enough replicas available for query at consistency LOCAL_QUORUM (2 required but only 1 alive". Any advice will be appreciated.

Maven dependencies:

org.springframework.boot:spring-boot:jar:2.3.7.RELEASE  org.springframework.boot:spring-boot-starter-data-cassandra:jar:2.3.7.RELEASE  org.springframework.data:spring-data-cassandra:jar:3.0.6.RELEASE  

YAML:

  spring:    data:      cassandra:        consistency-level: local_quorum        serial-consistency-level: LOCAL_SERIAL        local-datacenter: DC1        other configs: ...  

Code:

public class CassandraConfig {        @Bean      public CqlSessionBuilderCustomizer sessionBuilderConfigurer() {          return cqlSessionBuilder ->                  cqlSessionBuilder                          .withAuthCredentials("username", "pwd");      }        @Bean      public DriverConfigLoaderBuilderCustomizer driverConfigLoaderBuilderCustomizer() {          return loaderBuilder -> loaderBuilder                  .withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofMillis(10000))                  .withBoolean(DefaultDriverOption.LOAD_BALANCING_DC_FAILOVER_ALLOW_FOR_LOCAL_CONSISTENCY_LEVELS, true)                  .withInt(DefaultDriverOption.LOAD_BALANCING_DC_FAILOVER_MAX_NODES_PER_REMOTE_DC, 3);      }  }  
https://stackoverflow.com/questions/65854740/micro-service-with-spring-cassandra-doesnt-failover-to-remote-cluster January 23, 2021 at 09:03AM

没有评论:

发表评论