我正试图通过以下配置将我的服务与AWS Cassandra(Keyspaces
(集成:
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
中,问题仍然存在。
我认为在这个例子中需要调整变量。Apache Cassandra或Amazon密钥空间的常见语法是host:port
。对于Amazon Keyspaces,端口始终为9142。
尝试以下操作:
contact-points:
- ${CASSANDRA_HOST}:${CASSANDRA_PORT}
或者一开始只是对它们进行硬编码。
contact-points:
- cassandra.eu-west-1.amazonaws.com:9142
因此:
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上查找。