Cassandra:NoHostAvailableException:所有主机尝试查询失败
Posted
技术标签:
【中文标题】Cassandra:NoHostAvailableException:所有主机尝试查询失败【英文标题】:Cassandra :NoHostAvailableException: All host(s) tried for query failed 【发布时间】:2021-09-16 15:47:28 【问题描述】:我正在将最简单策略 Cassandra 的数据库中的数据复制到另一个数据库中。它们具有相同的键空间结构。但是,当我运行命令 sstableloader --nodes 时出现以下错误。有谁知道如何解决这个错误?
Cassandra 的版本: 3.11.10
命令行: # sstableloader --nodes 127.0.0.0 /var/lib/cassandra/loadme/keyspace/table01-5eef6110d04111ebb620bd376a9dc9e9/snapshots/dropped-1624306636002-table01
堆栈跟踪错误:
All host(s) tried for query failed (tried: /127.0.0.0:9042 (com.datastax.driver.core.exceptions.TransportException: [/127.0.0.0] Cannot connect))
com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.0:9042 (com.datastax.driver.core.exceptions.TransportException: [/127.0.0.0] Cannot connect))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:233)
at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:79)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1424)
at com.datastax.driver.core.Cluster.init(Cluster.java:163)
at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:334)
at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:309)
at com.datastax.driver.core.Cluster.connect(Cluster.java:251)
at org.apache.cassandra.utils.NativeSSTableLoaderClient.init(NativeSSTableLoaderClient.java:73)
at org.apache.cassandra.io.sstable.SSTableLoader.stream(SSTableLoader.java:159)
at org.apache.cassandra.tools.BulkLoader.load(BulkLoader.java:80)
at org.apache.cassandra.tools.BulkLoader.main(BulkLoader.java:48)
Exception in thread "main" org.apache.cassandra.tools.BulkLoadException: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.0:9042 (com.datastax.driver.core.exceptions.TransportException: [/127.0.0.0] Cannot connect))
at org.apache.cassandra.tools.BulkLoader.load(BulkLoader.java:93)
at org.apache.cassandra.tools.BulkLoader.main(BulkLoader.java:48)
Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.0:9042 (com.datastax.driver.core.exceptions.TransportException: [/127.0.0.0] Cannot connect))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:233)
at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:79)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1424)
at com.datastax.driver.core.Cluster.init(Cluster.java:163)
at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:334)
at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:309)
at com.datastax.driver.core.Cluster.connect(Cluster.java:251)
at org.apache.cassandra.utils.NativeSSTableLoaderClient.init(NativeSSTableLoaderClient.java:73)
at org.apache.cassandra.io.sstable.SSTableLoader.stream(SSTableLoader.java:159)
at org.apache.cassandra.tools.BulkLoader.load(BulkLoader.java:80)
... 1 more
【问题讨论】:
Cassandra 是否在 127.0.0.0 上启动并运行? 是的。标准配置和最简单的策略键空间。 “netstat -tln | grep 9042”返回什么,省略 qoutes? @apesa,这是命令的返回:tcp 0 0 127.0.0.1:9042 0.0.0.0:* LISTEN
【参考方案1】:
在您的命令行中,您传递了--nodes 127.0.0.0
,但在 netstat 输出端口 9042(本机传输)正在侦听 127.0.0.1。尝试将命令行更改为--nodes 127.0.0.1
当您收到错误 All host(s) tried for query failed
并且 nodetool 指示您的集群已启动并运行时,请始终确保正确的端口绑定到您的 IP 或 localhost。
【讨论】:
以上是关于Cassandra:NoHostAvailableException:所有主机尝试查询失败的主要内容,如果未能解决你的问题,请参考以下文章
Cassandra数据库从入门到精通系列之一:认识Cassandra数据库
Cassandra 2.2.1 不会开始使用 cassandra -f