Cassandra查询失败:所有尝试查询的主机均失败(未尝试任何主机) [英] Cassandra Query Failures: All host(s) tried for query failed (no host was tried)
本文介绍了Cassandra查询失败:所有尝试查询的主机均失败(未尝试任何主机)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法对Cassandra节点进行查询。我可以建立与群集的连接并进行连接。但是,在执行查询时,它会失败
I am not able to do queries against the Cassandra Node. I am able to make the connection to the cluster and connect. However while doing the the query, it fails
Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (no host was tried)
at com.datastax.driver.core.RequestHandler.reportNoMoreHosts(RequestHandler.java:217)
at com.datastax.driver.core.RequestHandler.access$1000(RequestHandler.java:44)
at com.datastax.driver.core.RequestHandler$SpeculativeExecution.sendRequest(RequestHandler.java:276)
at com.datastax.driver.core.RequestHandler.startNewExecution(RequestHandler.java:117)
at com.datastax.driver.core.RequestHandler.sendRequest(RequestHandler.java:93)
at com.datastax.driver.core.SessionManager.executeAsync(SessionManager.java:127)
... 3 more
这就是我连接到群集:
List<String> servers = config.getCassandraServers();
Builder builder = Cluster.builder();
for (String server : servers) {
builder.addContactPoints(server);
}
PoolingOptions opts = new PoolingOptions();
opts.setCoreConnectionsPerHost(HostDistance.LOCAL, opts.getCoreConnectionsPerHost(HostDistance.LOCAL));
// setup socket exceptions
SocketOptions socketOpts = new SocketOptions();
socketOpts.setReceiveBufferSize(1048576);
socketOpts.setSendBufferSize(1048576);
socketOpts.setTcpNoDelay(false);
cluster = builder.withSocketOptions(socketOpts)
.withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)
.withPoolingOptions(opts)
.withReconnectionPolicy(new ConstantReconnectionPolicy(100L))
.withLoadBalancingPolicy(new DCAwareRoundRobinPolicy(getColo(config)))
.build();
cluster.connect();
我正在使用带有Datastax驱动程序的最新稳定版本的Cassandra 2.2.3:
I am using latest stable version of Cassandra 2.2.3 with the Datastax driver:
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>2.1.8</version>
</dependency>
任何指针都受到高度赞赏
Any pointers are highly appreciated
谢谢
Masti
Thanks Masti
推荐答案
这是解决方案:问题出在
Here is the solve: Issue was with
.withLoadBalancingPolicy(new DCAwareRoundRobinPolicy(getColo(config)))
在这里,我在AWS云中只有一个节点来测试我的适配器,这使Cassandra脱颖而出。删除即可解决问题
Here I only have a single node in AWS cloud to test my adapter and it was throwing Cassandra off. Removing that solves the issue
谢谢
这篇关于Cassandra查询失败:所有尝试查询的主机均失败(未尝试任何主机)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文