Cassandra datastax操作时间异常
我正在使用部署在3个不同VM上的3节点cassandra 3.0.14。我有很多数据(数十亿),我想在我的卡桑德拉架构中快速搜索 我对卡桑德拉做了很多研究,但仍面临一些我无法理解的问题: 1-当我使用cqlsh时,我可以进行一个分析我所有数据库的查询Cassandra datastax操作时间异常,cassandra,Cassandra,我正在使用部署在3个不同VM上的3节点cassandra 3.0.14。我有很多数据(数十亿),我想在我的卡桑德拉架构中快速搜索 我对卡桑德拉做了很多研究,但仍面临一些我无法理解的问题: 1-当我使用cqlsh时,我可以进行一个分析我所有数据库的查询 从myTable中选择DISTINCT val_1正在工作 但是,我不能使用java代码和datastax驱动程序发出相同的请求。我的脚本返回: 原因:com.datastax.driver.core.exceptions.OperationTim
从myTable中选择DISTINCT val_1代码>正在工作
但是,我不能使用java代码和datastax驱动程序发出相同的请求。我的脚本返回:
原因:com.datastax.driver.core.exceptions.OperationTimedOutException:[/XX.XX.XX.XX:9042]等待服务器响应时超时
2-某些请求正在使用cqlsh工作,但发出更具体的请求将导致请求超时:
OperationTimedOut:errors={'127.0.0.1':'Client request timeout.请参阅Session.execute[\u async](timeout)},last\u host=127.0.0.1
例如,如果我提出此请求:
从myTable中选择val_1,其中时间>'2018-09-16 09:00:00'代码>将起作用
从myTable中选择val_1,其中time>'2018-09-16 09:00:00',time尝试在Java代码中调整客户端超时,如下所示:
//configure socket options
SocketOptions options = new SocketOptions();
options.setConnectTimeoutMillis(30000);
options.setReadTimeoutMillis(300000);
options.setTcpNoDelay(true);
//spin up a fresh connection (using the SocketOptions set up above)
cluster = Cluster.builder().addContactPoint(Configuration.getCassandraHost()).withPort(Configuration.getCassandraPort())
.withCredentials(Configuration.getCassandraUser(), Configuration.getCassandraPass()).withSocketOptions(options).build();
这是因为您使用卡桑德拉的方式不正确。只有在查询中指定了分区键时,范围操作、distinct等才能发挥最佳效果。否则,Cassandra将需要扫描整个集群,试图找到所需的数据,这将导致即使在中型数据库上也会超时。不要使用ALLOW FILTERING
强制执行查询
在Cassandra中,数据库结构是围绕要执行的查询建模的。我建议您选择DS201和DS220