1

我正在尝试Keyspaces使用以下配置将我的服务与 AWS Cassandra ( ) 集成:

    cassandra:
      default:
        advanced:
          ssl: true
          ssl-engine-factory: DefaultSslEngineFactory
          metadata:
            schema:
              enabled: false
          auth-provider:
            class: PlainTextAuthProvider
            username: "XXXXXX"
            password: "XXXXXX"
        basic:
          contact-points:
            - ${CASSANDRA_HOST:"127.0.0.1"}:${CASSANDRA_PORT:"9042"}
          load-balancing-policy:
            local-datacenter: "${CASSANDRA_DATA_CENTER}:datacenter1"
          session-keyspace: "keyspace"

每当我运行该服务时,它无法加载并出现以下错误:

Message: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=cassandra.eu-west-1.amazonaws.com/3.248.244.41:9142, hostId=null, hashCode=7296b27b): [com.datastax.oss.driver.api.core.DriverTimeoutException: [s0|control|id: 0x1f1c50a1, L:/172.17.0.3:54802 - R:cassandra.eu-west-1.amazonaws.com/3.248.244.41:9142] Protocol initialization request, step 1 (OPTIONS): timed out after 5000 ms]

关于图书馆的文档很少cassandra-micronaut,所以我不确定我在这里做错了什么。

更新:

为了清楚起见:我们的环境变量的值如下:

   export CASSANDRA_HOST=cassandra.eu-west-1.amazonaws.com
   export CASSANDRA_PORT=9142
   export CASSANDRA_DATA_CENTER=eu-west-1

请注意,即使我已将值硬编码到我application.yml的问题中,问题仍在继续。

4

2 回答 2

1

我认为您需要在此示例中调整变量。Apache Cassandra 或 Amazon Keyspaces 的常用语法是host:port. 对于 Amazon Keyspaces,端口始终为 9142。

尝试以下操作:

contact-points:
 - ${CASSANDRA_HOST}:${CASSANDRA_PORT}

或者一开始只是对它们进行硬编码。

contact-points:
 - cassandra.eu-west-1.amazonaws.com:9142
于 2021-08-13T18:03:25.960 回答
0

所以这:

contact-points:
    - ${CASSANDRA_HOST:"127.0.0.1"}:${CASSANDRA_PORT:"9042"}

与此不符:

Node(endPoint=cassandra.eu-west-1.amazonaws.com/3.248.244.41:9142,

仔细检查 Cassandra 正在广播的 IP 和端口(通常以 显示nodetool status)并调整服务以不在 127.0.0.1 上查找它。

于 2021-06-07T16:27:31.433 回答