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

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

问题描述

我知道有几个关于 NoHostAvailableException 的话题,但它们根本没有为我的问题提供解决方案.

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

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

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

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

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

我确定配置是正确的.我已经在 cassandra.yaml 中设置了配置:

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 

我的 Cassandra 安装是 AWS 上 EC2 实例上的标准安装.我已将 AWS 配置为允许端口 9042.

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

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

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

我的代码如下所示:

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?

推荐答案

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

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 

或到

rpc_address: 54.221.241.107  

看看它是否有帮助.请记住,ec2-ips 可能会在重新启动时发生变化.

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

我的猜测是绑定到ec-2的内部ip.如果您以这种方式向公众开放您的数据库,请记住添加一些安全性:-)

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天全站免登陆