首页 文章

错误NoHostAvailableException:尝试查询的所有主机都失败(尝试:/127.0.0.1:9042

提问于
浏览
0

我最近开始学习cassandra并使用DataStax Java驱动程序浏览cassandra的在线教程 . 我只是想在笔记本电脑上连接localhost节点 .

设置细节 -

操作系统 - 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();

此代码抛出异常 - Trace的一部分

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 OneQuestion twoQuestion threeTopicConnection requirementQuestion four .

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

请建议可能出错的地方 .

1 回答

  • 1

    schema_usertypes 的错误似乎是驱动程序试图寻找一个可能与此Jira无关的表 .

    你说你正在运行2.1-SNAPSHOT的Cassandra?试试Cassandra 2.1.15 . 在您的Cassandra节点上似乎有些东西,驱动程序能够与您的群集通信,因为它试图查找 schema_usertypes 中的数据 .

相关问题