cassandra的cqlsh控制台中的操作超时错误

问题描述 投票:14回答:7

我有三个节点Cassandra Cluster,我创建了一个表,其中有超过2,000,000行。

当我在cqlsh中执行此(select count(*) from userdetails)查询时,我收到此错误:

OperationTimedOut:errors = {},last_host = 192.168.1.2

当我为较少的行或限制50,000运行计数功能时,它工作正常。

java cassandra bigdata datastax cqlsh
7个回答
14
投票

count(*)实际上遍历所有数据。所以一个没有限制的select count(*) from userdetails预计将超过那么多行。这里有一些细节:http://planetcassandra.org/blog/counting-key-in-cassandra/

您可能需要考虑使用Spark自己维护计数,或者如果您只想要一个球场号码,您可以从JMX获取它。

要从JMX中获取它可能有点棘手,具体取决于您的数据模型。要获得分区数量,请​​抓住org.apache.cassandra.metrics:type=ColumnFamily,keyspace={{Keyspace}},scope={{Table​}},name=EstimatedColumnCountHistogram mbean并总结所有90个值(这是nodetool cfstats输出的内容)。它只会给你sstables中存在的数字,以便更准确你可以进行刷新或尝试估计来自MemtableColumnsCount mbean的memtables中的数字

对于一个非常基本的球场编号,您可以在列出的所有范围内从system.size_estimates获取估计的分区计数(请注意,这只是一个节点上的数字)。将其乘以节点数,然后除以RF。


9
投票

您还可以在cqlsh命令中增加超时,例如:

cqlsh --request-timeout 120 myhost

4
投票

要在Apache Cassandra中更改客户端超时限制,有两种方法:

技巧1:修改cqlshrc文件。

技巧2:打开程序cqlsh并使用client_timeout变量修改指定的时间。

有关完成的详细信息,请参阅链接:https://playwithcassandra.wordpress.com/2015/11/05/cqlsh-increase-timeout-limit/


2
投票

如果你使用cqlsh:在编辑器中打开脚本并找到所有单词“timeout”。将默认值从10更改为60并保存脚本。


2
投票

我正在使用Cassandra 3.4和cqlsh来获取记录计数。似乎3.4中的代码发生了变化。 cqlsh只调用cqlsh.py。在cqlsh.py里面有一个DEFAULT_REQUEST_TIMEOUT_SECONDS变量,默认为10(秒)。我将其更改为3600(1小时),现在我的SELECT count(*)查询工作。


0
投票

如果我计算一天,你会遇到与上面相同的问题,但作为解决方法,我将计数分成两个请求(12小时+ 12小时),如下所示。

cqlsh:jw_schema1> select count(*) from flight_statistics where insert_time >= '2015-08-20 00:00:00' and insert_time <= '2015-08-20 11:59:59' ALLOW FILTERING;

 count
-------
 42528

(1 rows)
cqlsh:jw_schema1> select count(*) from flight_statistics where insert_time >= '2015-08-20 12:00:00' and insert_time <= '2015-08-20 23:59:59' ALLOW FILTERING;

 count
-------
 86580

(1 rows)
cqlsh:jw_schema1> 

0
投票

我正在使用Cassandra 3.11和cqlsh获取记录计数。我的表大约有40,000,000行,我被迫遇到这个问题。我的问题解决了两个变化:

首先是在所有节点上更改'cassandra.yaml'中的所有超时配置:

# 3,600,000 is one hour in ms
read_request_timeout_in_ms: 3600000
range_request_timeout_in_ms: 3600000
write_request_timeout_in_ms: 3600000
counter_write_request_timeout_in_ms: 3600000
cas_contention_timeout_in_ms: 3600000
truncate_request_timeout_in_ms: 3600000
request_timeout_in_ms: 3600000
slow_query_log_timeout_in_ms: 3600000

然后在所有节点上重新启动cassandra。

第二个是运行'cqlsh',指定超时如下:

cqlsh --request-timeout=3600000 <myhost>
© www.soinside.com 2019 - 2024. All rights reserved.