Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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);
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...