Cassandra 问题 v3.11.3 ... select count(*) from table1

Cassandra question v3.11.3 ... select count(*) from table1

我在 table 中导入了 1 条以上的核心记录,当我执行 Select 查询计数 (*) 时,出现错误。我知道这是一个昂贵的查询,但是任何人都可以帮助我获得相同的解决方案。

SELECT 从表 1 计数 (*);

错误:OperationTimedOut:错误={'10.20.30.10':'Client request timeout. See Session.execute_async'},last_host=10.20.30.10

因此,如果这是一个生产系统,则可能不会,但您似乎已经意识到了这一点。

> cqlsh --request-timeout=3600
SELECT count(*) FROM table1 ALLOW FILTERING;

您的系统正在超时,因为查询开销很大,这就是您的错误所在。您可以延长超时时间来解决这个问题,但在某些时候,如果您的数据集足够大,cassandra 将无法返回。此外,您可能希望 运行 您的查询具有 ONE 的一致性,这样您就不会触发读取压缩并且它会更快地返回。它当然会不太准确。

您也可以尝试:nodetool cfstats mykeyspace这只是一个估计值,但总比没有好。

经过多次研发,我找到了 count(*) 问题的解决方案。

步数:

  1. 在Cassandra Cluster上设置presto(我使用了presto-server-0.215版本(presto-server-0.215.tar.gz并使用了jdk:jdk-8u151-linux-x64.tar.gz)) 1.1. presto-server-0.215.tar.gz: https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.215/ 1.2. jdk-8u151-linux-x64.tar.gz: https://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html
  2. 在一台cassandra服务器上安装presto,这将使它成为协调器,集群中的其余节点将成为工作节点,请参考下面URL设置presto。 参考 URL: https://github.com/prestodb/presto/issues/3382
  3. 您需要为您在 config.properties 文件中提到的 Presto 端口添加防火墙规则(我使用的是 RHEL 7.x OS)
  4. 在 launcher.py 中进行更改 ---> 安装 jdk 的行号“214”路径 "command = ['/opt/jdk1.8.0_151/bin/java', '-cp', classpath]"
  5. 开始 presto ---> ./launcher start
  6. 打开 presto 控制台 http://localhost:8081,您应该会在控制台中看到协调器和工作节点。

  7. 下载"presto-cli-0.215-executable.jar"(URL:https://prestodb.io/docs/current/installation/cli.html)重命名为prestocli(给755权限)然后测试count(*)大table 使用 'prestocli' a table 有 750 万条记录,当我们在 cqlsh 中 运行 时出现错误。 7.1. CQLSH 错误:来自服务器的错误:代码=1200 [协调器节点等待副本节点响应超时] 消息="Operation timed out - received only 0 responses." 信息={'received_responses': 0, 'required_responses': 1, 'consistency': 'ONE'}

  8. 下面是 count(*)...
  9. 的解决方案

[root@casdb01 bin]# ./prestocli --server localhost:8081 转瞬即逝> SELECT count(*) FROM cassandra.datamart.big_table;

_col0

7587418 (1 行)

查询 20190118_070908_00005_38tiw,已完成,1 个节点 劈叉:总计 1,298 次,完成 1,298 次 (100.00%) 0:53 [7.59M 行, 7.24MB] [142K rows/s, 139KB/s]

  1. 对于任何应用程序查询,您都可以将 presto 作为接口来执行计数 (*)。

特别感谢我的团队,他们帮助我获得了这个结果 (Venkatesh Bhat)。