【问题标题】:Failing to connect to Cassandra through Phantom (NoHostAvailableException)无法通过 Phantom 连接到 Cassandra (NoHostAvailableException)
【发布时间】:2016-05-23 04:06:47
【问题描述】:

尝试从 Scala 应用程序通过 Phantom 插入 Cassandra 时收到以下错误代码。

Cassandra 版本与:dsc-cassandra-3.0.1 捆绑在一起

[error] (run-main-0) com.datastax.driver.core.exceptions.NoHostAvailableException:所有主机尝试查询失败(尝试:localhost/127.0.0.1:9042(com.datastax.driver .core.exceptions.InvalidQueryException: 未配置的表 schema_keyspaces), localhost/0:0:0:0:0:0:0:1:9042 (com.datastax.driver.core.TransportException: [localhost/0:0:0 :0:0:0:0:1:9042] 无法连接)) com.datastax.driver.core.exceptions.NoHostAvailableException:所有主机尝试查询失败(尝试:localhost/127.0.0.1:9042(com.datastax.driver.core.exceptions.InvalidQueryException:未配置的表schema_keyspaces),本地主机/0:0:0:0:0:0:0:1:9042 (com.datastax.driver.core.TransportException: [localhost/0:0:0:0:0:0:0:1:9042]无法连接))

我已阅读 StackOverflow 中的其他此类问题,但尚未找到解决问题的方法。

此外,我没有注意到任何其他错误日志中存在以下内容:

我在阅读 localhost/127.0.0.1:9042 时是否正确

这不是归结为127.0.0.1/127.0.0.1:9402 - 这可以解释为什么它找不到正确的端口开放。

现在沿着这条路走,试图弄清楚这是否是一回事。

确保 Cassandra 正在运行。

我也跑了 sudo lsof -i -P | grep -i "listen" 输出如下(只提取 java 的):

java 4053 dan_mi_sun 85u IPv4 0xdbcce7039c377b9d 0t0 TCP localhost:7199 (LISTEN)
java 4053 dan_mi_sun 86u IPv4 0xdbcce703986952cd 0t0 TCP localhost:53680 (LISTEN)
java 4053 dan_mi_sun 92u IPv4 0xdbcce7039869b46d 0t0 TCP localhost:7002 (LISTEN)
java 4053 dan_mi_sun 145u IPv4 0xdbcce7039c37846d 0t0 TCP localhost:9042 (LISTEN)

你有什么想法吗?

找到了这个,但不确定它是否相关:

https://datastax-oss.atlassian.net/browse/JAVA-897

如果在这里有用的话,build.sbt

name := "SuperChain"

organization := "org.dyne.danielsan"

version := "0.1.0-SNAPSHOT"

scalaVersion := "2.11.7"

crossScalaVersions := Seq("2.10.4", "2.11.2")

resolvers ++= Seq(
  "Typesafe repository snapshots" at "http://repo.typesafe.com/typesafe/snapshots/",
  "Typesafe repository releases" at "http://repo.typesafe.com/typesafe/releases/",
  "Sonatype repo"                    at "https://oss.sonatype.org/content/groups/scala-tools/",
  "Sonatype releases"                at "https://oss.sonatype.org/content/org.dyne.danielsan.superchain.data.cassandra.init.repositories/releases",
  "Sonatype snapshots"               at "https://oss.sonatype.org/content/org.dyne.danielsan.superchain.data.cassandra.init.repositories/snapshots",
  "Sonatype staging"                 at "http://oss.sonatype.org/content/org.dyne.danielsan.superchain.data.cassandra.init.repositories/staging",
  "Java.net Maven2 Repository"       at "http://download.java.net/maven/2/",
  "Twitter Repository"               at "http://maven.twttr.com",
  "Wedsudos Bintray Repo"            at "https://dl.bintray.com/websudos/oss-releases/"
)

libraryDependencies ++= Seq(
  "com.websudos" %% "phantom-dsl" % "1.12.2",
  "org.scalatest" %% "scalatest" % "2.2.1" % "test",
  "org.scalacheck" %% "scalacheck" % "1.11.5" % "test"
)

initialCommands := "import org.dyne.danielsan.superchain._"

【问题讨论】:

    标签: java scala cassandra datastax phantom-dsl


    【解决方案1】:

    此错误:com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table schema_keyspaces 让我相信您使用的幻影版本未使用 datastax java-driver 3.0+。由于您要连接到 3.0 集群,因此您需要一个能够理解模式表的 3.0 驱动程序(system_schema.* 而不是 system.schema*)。如果您升级到 phantom-dsl 1.21.0,应该可以解决问题。

    【讨论】:

      猜你喜欢
      • 2013-09-14
      • 2017-04-16
      • 2016-04-03
      • 2017-04-05
      • 2018-08-12
      • 2014-08-07
      • 2016-02-06
      • 1970-01-01
      • 2017-12-23
      相关资源
      最近更新 更多