Cassandra超时cqlsh查询大(ish)数据量

时间:2015-04-03 18:12:54

标签: cassandra timeout cqlsh

我正在做一个涉及构建和查询Cassandra数据集群的学生项目。

当我的群集负载很轻(大约30GB)时,我的查询运行没有问题,但现在它的数量要大得多(1 / 2TB)我的查询超时。

我认为可能会出现此问题,因此在开始生成和加载测试数据之前,我已在cassandra.yaml文件中更改了此值:

  

request_timeout_in_ms   (默认值:10000)其他杂项操作的默认超时。

但是,当我将该值更改为1000000时,cassandra似乎在启动时挂起 - 但这可能只是工作中的大超时。

我的数据生成目标是2TB。如何查询大量空间而不会遇到超时?

查询:

SELECT  huntpilotdn 
FROM    project.t1 
WHERE   (currentroutingreason, orignodeid, origspan,  
        origvideocap_bandwidth, datetimeorigination)
        > (1,1,1,1,1)
AND      (currentroutingreason, orignodeid, origspan,    
         origvideocap_bandwidth, datetimeorigination)
         < (1000,1000,1000,1000,1000)
LIMIT 10000
ALLOW FILTERING;

SELECT  destcause_location, destipaddr
FROM    project.t2
WHERE   datetimeorigination = 110
AND     num >= 11612484378506
AND     num <= 45880092667983
LIMIT 10000;


SELECT  origdevicename, duration
FROM    project.t3
WHERE   destdevicename IN ('a','f', 'g')
LIMIT 10000
ALLOW FILTERING;

我有一个具有相同模式的演示密钥空间,但数据大小要小得多(~10GB),并且这些查询在该密钥空间中运行得很好。

所有这些查询的表都有数百万行,每行约30列。

5 个答案:

答案 0 :(得分:43)

如果您使用的是数据共享cqlsh,则可以将客户端超时秒指定为命令行参数。默认值为10

$ cqlsh --request-timeout=3600

Datastax Documentation

答案 1 :(得分:8)

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

技术1:这是一项很好的技巧:

1. Navigate to the following hidden directory under the home folder: (Create the hidden directory if not available)

    $ pwd
    ~/.cassandra


2. Modify the file cqlshrc in it to an appropriate time in seconds: (Create the file if not available)

    Original Setting:

        $ more cqlshrc
        [connection]
        client_timeout = 10
        # Can also be set to None to disable:
        # client_timeout = None
        $

    New Setting:

        $ vi cqlshrc
        $ more cqlshrc
        [connection]
        client_timeout = 3600
        # Can also be set to None to disable:
        # client_timeout = None
        $

    Note: Here time is in seconds. Since, we wanted to increase the timeout to one hour. Hence, we have set it to 3600 seconds.

技术2:这不是一个好技术,因为您正在更改客户端程序(cqlsh)本身的设置。 注意:如果您已使用技术1进行了更改 - 那么它将覆盖使用技术2指定的时间。因为,配置文件设置具有最高优先级。

1. Navigate to the path where cqlsh program is located. This you can find using the which command:

    $ which cqlsh
    /opt/apache-cassandra-2.1.9/bin/cqlsh
    $ pwd
    /opt/apache-cassandra-2.1.9/bin
    $ ls -lrt cqlsh
    -rwxr-xr-x 1 abc abc 93002 Nov  5 12:54 cqlsh


2. Open the program cqlsh and modify the time specified using the client_timeout variable. Note that time is specified in seconds.
$ vi cqlsh

In __init__ function:
    def __init__(self, hostname, port, color=False,
                 username=None, password=None, encoding=None, stdin=None, tty=True,
                 completekey=DEFAULT_COMPLETEKEY, use_conn=None,
                 cqlver=DEFAULT_CQLVER, keyspace=None,
                 tracing_enabled=False, expand_enabled=False,
                 display_time_format=DEFAULT_TIME_FORMAT,
                 display_float_precision=DEFAULT_FLOAT_PRECISION,
                 max_trace_wait=DEFAULT_MAX_TRACE_WAIT,
                 ssl=False,
                 single_statement=None,
                 client_timeout=10,
                 connect_timeout=DEFAULT_CONNECT_TIMEOUT_SECONDS):

In options.client_timeout setting:
    options.client_timeout = option_with_default(configs.get, 'connection', 'client_timeout', '10')

You can modify at both these places. The second line picks up client_timeout information from the cqlshrc file.

答案 2 :(得分:6)

我猜你也在使用二级索引。您正在发现为什么不建议使用二级索引查询和允许过滤查询...因为这些类型的设计模式不适用于大型数据集。使用支持主键查找的查询表重建模型,因为这就是Cassandra的工作方式。

修改

&#34;受约束的变量是群集密钥。&#34;

正确...这意味着它们不是分区键。在不限制分区键的情况下,您基本上扫描整个表,因为群集密钥仅在其分区键中有效(群集数据)。

答案 3 :(得分:4)

使用-request-timeout (以秒为单位)作为cqlsh的CLI参数,如下所示:

$ cqlsh --request-timeout=3600

答案 4 :(得分:1)

  1. 增加cassandra.yaml文件中的read_request_timeout_in_sec

  2. 修改cqlsh.py程序并更改变量值,而不是在函数中进行更改。 DEFAULT_REQUEST_TIMEOUT_SECONDS = 100 DEFAULT_CONNECT_TIMEOUT_SECONDS = 100

可以肯定