java - 错误 NoHostAvailableException : All host(s) tried for query failed (tried:/127. 0.0.1:9042

标签 java cassandra connection datastax

我最近开始学习 cassandra 并通过 DataStax Java 驱动程序浏览 cassandra 在线教程。我只是想连接我的笔记本电脑上的本地主机节点。

设置详细信息 -

操作系统 - Windows 7

Cassandra 版本 - Cassandra 版本:2.1-SNAPSHOT

DataStax java 驱动程序版本 - 3.1.0

我可以使用 CQLSH 和 cassandra-cli 客户端连接到本地节点。 我还可以看到默认的键空间系统和 system_traces。 以下是 cassandra 服务器日志

INFO  12:12:51 Node localhost/127.0.0.1 state jump to normal
INFO  12:12:51 Startup completed! Now serving reads.
INFO  12:12:51 Starting listening for CQL clients on /0.0.0.0:9042...
INFO  12:12:51 Binding thrift service to /0.0.0.0:9160
INFO  12:12:51 Using TFramedTransport with a max frame size of 15728640 bytes.
INFO  12:12:51 Using synchronous/threadpool thrift server on 0.0.0.0 : 9160
INFO  12:12:51 Listening for thrift clients...

我正在尝试下面的简单代码 -

        Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1").build();
        Metadata metadata = cluster.getMetadata();

此代码引发以下异常 - 跟踪的一部分

com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:9042 (com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured columnfamily schema_usertypes))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:233)

我已经回答了之前提出的所有问题。大多数答案建议更改 cassandra.yaml 文件中的配置。

我的 cassandra.yaml 配置是 -

start_native_transport: true
native_transport_port: 9042
listen_address: localhost
rpc_address: 0.0.0.0
rpc_port: 9160

大多数答案建议在 rpc_address 处使用机器的实际 IP 地址,我尝试过但没有成功。

以下是我遇到过的问题 - Question One , Question two , Question three , Topic , Connection requirement , Question four .

This page列出了Java DataStax驱动程序与cassandra版本的兼容性,因此我将驱动程序版本更改为2.1.1(因为我使用的是cassandra 2.1),但它不起作用。

请提出可能存在问题的建议。

最佳答案

schema_usertypes 的错误似乎是驱动程序正在尝试查找不存在的表,可能与此 Jira 有关。 。

您说您正在运行 Cassandra 的 2.1-SNAPSHOT?尝试 Cassandra 2.1.15。您的 Cassandra 节点上似乎出现问题,驱动程序能够与您的集群通信,因为它尝试在 schema_usertypes 中查找数据。

关于java - 错误 NoHostAvailableException : All host(s) tried for query failed (tried:/127. 0.0.1:9042,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39932666/

相关文章:

java - 用用户命名的java在mysql中创建一个表?

java - 如何在运行时检查是否声明了 NamedNativeQuery

cassandra - 清理几乎已满的 Cassandra 节点中的空间

oracle - 如何更改连接中的 Oracle 客户端用户

java - 如何使用 JFileChooser 在 Java 中保存文件

cassandra - 如何允许不同的键空间在 Cassandra 中使用不同的分区器?

cassandra - Apache Cassandra 如何与 Infinispan 融合?

c# - ExecuteReader : Connection property has not been initialized. 如何解决这个问题?

c# - 来电者完成连接后,我如何关闭连接?

java - 创建 Web 服务时出现 Eclipse Axis 错误