【发布时间】:2013-08-11 09:23:11
【问题描述】:
我的笔记本电脑上有一个基本的 cassandra 设置,它已启动,我可以使用命令行工具连接到它,但是在 java 中,以下失败:
Cluster cluster = new Cluster.Builder().addContactPoints("localhost").withPort(9160).build();
任何线索都会非常有帮助,谢谢!错误是:
com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: localhost/127.0.0.1 ([localhost/127.0.0.1] Unexpected error during transport initialization (com.datastax.driver.core.TransportException: [localhost/127.0.0.1] Channel has been closed)))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:186)
【问题讨论】:
-
我在使用 cassandra jdbc 库时也没有问题。
-
我知道我可能听起来很愚蠢,但 Cassandra 正在运行吗?
-
@Chiron 它没有,这正是问题所在。 @Jacob 使用
telnet 127.0.0.1 9160验证 cassandra 是否正在运行 -
检查 cassandra 的日志文件是否有错误和警告
-
检查cassandra配置中的接口设置是否正确:如果你想让cassandra监听多个ip-adress(如果你想使用localhost和ip-adress就是这种情况为网络连接指定),那么您必须在配置中使用 0.0.0.0 作为 Ip-Adress。