无法连接到cassandra - NoHostAvailableException [英] Can't connect to cassandra - NoHostAvailableException

查看:2239
本文介绍了无法连接到cassandra - NoHostAvailableException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有几个线程关于 NoHostAvailableException ,但他们根本不提供解决我的问题。



我无法使用Datastax Java Cassandra驱动程序连接到Cassandra。我收到错误:


com.datastax.driver.core.exceptions.NoHostAvailableException:所有
主机查询失败(尝试:[/54.221.241.107])


我确定配置正确。我在cassandra.yaml中设置了配置:

  start_native_transport:true 
用于CQL本地传输的端口在
上听取客户
native_transport_port:9042

我的Cassandra安装是EC2实例。



Cassandra在Windows Server 2008 R2上运行,我还在9042上将防火墙配置为入站和出站连接。



我的代码如下所示:

  cluster = Cluster.builder 
.withPort(9042)
.addContactPoint(54.221.241.107)。build();

我不知道该怎么做,因为我总是得到这个错误。有任何建议吗?

解决方案

检查您的casssandra.yaml文件。 native_transport使用与rpc_address相同的地址绑定。如果它绑定到另一个地址比54.221.241.107,你会得到这个问题。
尝试将其设置为

  rpc_address:0.0.0.0 
pre>

  rpc_address:54.221.241.107 

,看看它是否有帮助。请记住,ec2-ips可能会在重新启动时更改。



我的猜测是,绑定到ec-2的内部ip。并记住添加一些安全,如果你打开你的数据库公共这样: - )


I know there are several threads about the NoHostAvailableException but they simply don't provide a solution to my problem.

I can't connect to Cassandra with the Datastax Java Cassandra Driver. I get the Error:

com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: [/54.221.241.107])

I am sure that the configuration is correct. I've set the configuration in cassandra.yaml:

start_native_transport: true 
# port for the CQL native transport to listen for clients on 
native_transport_port: 9042 

My Cassandra installation is a standard installation on a EC2 instance on AWS. I've configured AWS to allow port 9042.

Cassandra is running on Windows Server 2008 R2 and I also configured the firewall to inbound and outbound connection on 9042.

My code looks like the following:

cluster = Cluster.builder()
  .withPort(9042)
  .addContactPoint("54.221.241.107").build();

I don't know what to do anymore since I always get this error. Any suggestions?

解决方案

Check your casssandra.yaml file. The native_transport uses the same address binding as the rpc_address. If it is bound to another address than "54.221.241.107" you would get this problem. Try setting it to

rpc_address: 0.0.0.0 

or to

rpc_address: 54.221.241.107  

and see if it helps. Keep in mind that ec2-ips might change on restarts.

My guess is that is is bound to the internal ip of the ec-2. And remember to add some security if you are opening up your database to the public this way :-)

这篇关于无法连接到cassandra - NoHostAvailableException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆