【问题标题】:Error NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:9042错误 NoHostAvailableException:尝试查询的所有主机都失败(尝试:/127.0.0.1:9042
【发布时间】:2017-02-17 08:43:24
【问题描述】:

我最近开始学习 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();

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

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),但它不起作用。

请提出可能的问题。

【问题讨论】:

    标签: java cassandra connection datastax


    【解决方案1】:

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

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

    【讨论】:

    • 使用 Cassandra-2.1.15。使用两个版本的驱动程序 - 3.1.0 和 2.1.1
    • 我在连接集群 spring.data.cassandra.contact-points=10.202.82.25,10.180.19.157,10.180.12.222 时遇到了类似的问题......得到错误所有主机( s) 尝试查询失败(尝试:localhost/0:0:0:0:0:0:0:1:9042 (com.datastax.driver.core.exceptions.TransportException: [localhost/0:0:0: 0:0:0:0:1:9042] 无法连接),localhost/127.0.0.1:9042(com.datastax.driver.core.exceptions.TransportException: [localhost/127.0.0.1:9042] 无法连接))。 ..我在哪里得到这个 127.0.0.1 主机?请让我知道我在这里做错了什么?
    猜你喜欢
    • 1970-01-01
    • 2019-02-25
    • 2021-01-30
    • 2019-03-14
    • 2023-03-20
    • 2016-02-13
    • 2015-01-03
    • 2019-01-18
    • 1970-01-01
    相关资源
    最近更新 更多