【问题标题】:Unsupported partitioner with Amazon Keyspaces (for Apache Cassandra)不支持使用 Amazon Keyspaces 的分区程序(适用于 Apache Cassandra)
【发布时间】:2020-07-30 11:08:29
【问题描述】:

我有一个 Java Spring 应用程序,我正在使用 Amazon Keyspaces (for Apache Cassandra)。我正在使用sigv4 plugin(4.0.2 版)、cassandra java-driver-core(4.4.0 版),并遵循了有关如何将我的 java 应用程序与 MCS 连接的官方文档。该应用程序连接得很好,但我在启动时收到了一个奇怪的警告:

WARN 1 --- [     s0-admin-0] .o.d.i.c.m.t.DefaultTokenFactoryRegistry : [s0] Unsupported partitioner 'com.amazonaws.cassandra.DefaultPartitioner', token map will be empty.

一切看起来都不错,但几分钟后,警告又回来了,我的查询开始失败。这是几分钟后日志的样子:

WARN 1 --- [     s0-admin-0] .o.d.i.c.m.t.DefaultTokenFactoryRegistry : [s0] Unsupported partitioner 'com.amazonaws.cassandra.DefaultPartitioner', token map will be empty.
WARN 1 --- [        s0-io-1] c.d.o.d.i.c.m.SchemaAgreementChecker     : [s0] Unknown peer xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, excluding from schema agreement check
WARN 1 --- [        s0-io-0] c.d.o.d.i.c.control.ControlConnection    : [s0] Unexpected error while refreshing schema after a successful reconnection, keeping previous version (CompletionException: com.datastax.oss.driver.api.core.connection.ClosedConnectionException: Channel was force-closed)
WARN 1 --- [        s0-io-1] c.d.o.d.i.c.m.DefaultTopologyMonitor     : [s0] Control node ec2-x-xx-xxx-xx.us-east-2.compute.amazonaws.com/x.xx.xxx.xxx:xxxx has an entry for itself in system.peers: this entry will be ignored. This is likely due to a misconfiguration; please verify your rpc_address configuration in cassandra.yaml on all nodes in your cluster.

我调试了一下,看起来分区器来自实际的节点元数据,所以我真的不知道是否有实际的方法来修复它。

我看到最近here 有人问过类似的问题,但尚未发布任何解决方案。有任何想法吗?提前非常感谢

【问题讨论】:

  • 亚马逊没有向官方驱动程序提供所需的实现,所以不存在这样的解决方案......也许他们在他们网站的某个地方发布了驱动程序?
  • @AlexOtt 感谢您的回复。连接到 AWS MCS(现为 AWS Keyspaces)uses the datastax java plugin 所需的 aws 插件。所以不幸的是,我认为现在没有其他选择。

标签: java amazon-web-services cassandra


【解决方案1】:

我也有同样的问题。

上述使用Spring boot 2.3.x版本时遇到的问题

因为是Spring boot 2.3.x版

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-cassandra-reactive</artifactId>
</dependency>

OR

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-cassandra</artifactId>
</dependency> 

创建 Maven / Gradle 时会得到 "datastax-java-driver-core 4.6.1",我认为这是 不支持 Amazon Keyspaces 的另一个原因。 >

好的,清除.....

回到 AWS 库的主题 aws-sigv4-auth-cassandra-java-driver-plugin 4.0.2

创建 Maven/Gradle 时会得到 "datastax-java-driver-core 4.4.0"

现在我开始看到 Amazon Keyspaces

可能不支持 "datastax-java-driver-core" 版本大于 4.4.0

好的,已经很久了。

如果你想让 Application Spring Boot 2 工作

您尝试遵循以下解决方案。

查看 pom.xml

  1. 删除 aws-sigv4-auth-cassandra-java-driver-plugin

  2. 将 Spring boot 版本 2.3.x 降级为 2.2.9

  3. 在下面添加依赖,

spring-boot-starter-data-cassandra-reactive 要么 spring-boot-starter-data-cassandra

  1. 创建亚马逊数字证书并下载

  2. 如果您使用 InteljiJ IDEA 编辑配置

转到 编辑配置 -> 下一个 VM 选项 在下面添加,

-Djavax.net.ssl.trustStore=path_to_file/cassandra_truststore.jks 

-Djavax.net.ssl.trustStorePassword=my_password

参考:https://docs.aws.amazon.com/keyspaces/latest/devguide/using_java_driver.html

  1. application-dev.yml 下面添加配置,
spring:
      data:
        cassandra:
          contact-points:
            - "cassandra.ap-southeast-1.amazonaws.com"
          port: 9142
          ssl: true
          username: "cassandra-username"
          password: "cassandra-password"
          keyspace-name: keyspace-name
          request:
            consistency: local_quorum
  1. 运行测试程序

通过。

为我工作。

技术栈

  • Spring Boot WebFlux 2.2.9.RELEASE
  • Cassandra 反应式
  • JDK 13
  • 带有 Amazon Keyspaces 的 Cassandra 数据库
  • Maven 3.6.3

享受编程的乐趣。

【讨论】:

  • 非常感谢您的回答。回到以前版本的 Spring Cassandra 就可以了!
【解决方案2】:

这些都是警告而不是错误。您的连接应该可以正常工作。由于 Amazon Keyspaces 与实际的 Cassandra 集群略有不同,因此会记录它们。尝试设置这些以消除噪音:

datastax-java-driver.advanced {
  metadata {
    schema.enabled = false
    token-map.enabled = false
  }
  connection.warn-on-init-error = false
}

【讨论】: