Cassandra连接异常 [英] Cassandra connection exception
问题描述
我有以下代码:
private final String CONTACT_POINT = "127.0.0.1";
private SynchronizationTableManager()
{
cluster = Cluster.builder().addContactPoint(CONTACT_POINT).build();;
session = cluster.connect(KEYSPACE);
createTableIfNotExists();
}
我遇到以下异常:
所有尝试查询的主机均失败(尝试:/127.0.0.1:9042(com.datastax.driver.core.TransportException:[/127.0.0.1:9042]无法连接)),带有堆栈跟踪:com.datastax.driver.core.exceptions.NoHostAvailableException:所有尝试查询的主机均失败(尝试:/127.0.0.1:9042(com.datastax.driver.core.TransportException:[/ 127.0.0.1:9042]无法连接))
All host(s) tried for query failed (tried: /127.0.0.1:9042 (com.datastax.driver.core.TransportException: [/127.0.0.1:9042] Cannot connect)) with stack trace: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:9042 (com.datastax.driver.core.TransportException: [/127.0.0.1:9042] Cannot connect))
这种情况发生在调用 cluster.connect(KEYSPACE )
。知道如何解决此问题吗?
This happens on the line calling cluster.connect(KEYSPACE)
. Any idea how to fix this?
推荐答案
这很可能是 cassandra.yaml 设置存在的问题。请检查 listen_address , rpc_address 和 broadcast_rpc_address 。
This is most likely a problem with cassandra.yaml settings. Please check the settings of listen_address, rpc_address, and broadcast_rpc_address.
还请检查Java驱动程序的连接要求: https://github.com/datastax/java-driver/wiki/Connection-requirements
Please also check the connection requirements for the Java driver: https://github.com/datastax/java-driver/wiki/Connection-requirements
还有什么 nodetool ring 告诉您有关C *节点的信息吗?您可以通过 cqlsh 连接到您的节点吗?
Also what does nodetool ring tell you about your C* node? Can you connect to your node over cqlsh?
这篇关于Cassandra连接异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!