代码之家  ›  专栏  ›  技术社区  ›  devThoughts

从CQL导出数据时出现RPC超时错误

  •  5
  • devThoughts  · 技术社区  · 11 年前

    我正在尝试使用CQL客户端从cassandra导出数据。一个列族中大约有100000行。当我使用COPY TO命令将dta复制到csv文件中时,我会出现以下rpc_time-out错误。

    copy mycolfamily to '/root/mycolfamily.csv'
    Request did not complete within rpc_timeout.
    

    我正在磨合:

    [cqlsh 3.1.6 | Cassandra 1.2.8 | CQL spec 3.0.0 | Thrift protocol 19.36.0]

    如何增加RPC超时限制?

    我试着添加 rpc_timeout_in_ms: 20000 (事实上是10000)在我的 conf/cassandra.yaml 文件但在重新启动cassandra时,我得到了:

    [root@user ~]# null; Can't construct a java object for tag:yaml.org,2002:org.apache.cassandra.config.Config; exception=Cannot create property=rpc_timeout_in_ms for JavaBean=org.apache.cassandra.config.Config@71bfc4fc; Unable to find property 'rpc_timeout_in_ms' on class: org.apache.cassandra.config.Config
    Invalid yaml; unable to start server.  See log for stacktrace.
    
    4 回复  |  直到 11 年前
        1
  •  5
  •   aacanakin    10 年前

    这个 COPY 命令当前对执行相同的操作 SELECT 具有 LIMIT 99999999 。因此,当您的数据增长时,它最终会超时。这是导出功能;

    https://github.com/apache/cassandra/blob/trunk/bin/cqlsh#L1524

    我在生产方面也做同样的出口。我正在做的是:;

    • 从表中选择*,其中timeuuid=someTimeuuid limit 10000
    • 将结果集写入csv文件w/>>模式
    • 相对于上次uuid进行下一次选择

    可以通过以下cqlsh命令在cqlsh中发送命令

    echo "{$cql}" | /usr/bin/cqlsh -u user -p password localhost 9160 > file.csv

        2
  •  2
  •   akshat thakar    10 年前

    您可以通过在Datastax Java驱动程序中指定提取大小来使用自动分页。

    Statement stmt = new SimpleStatement("SELECT id FROM mycolfamily;"); 
    stmt.setFetchSize(500); 
    session.execute(stmt); 
    for (Row r:result.all()){
        //write to file
    }
    
        3
  •  1
  •   safato    10 年前

    几分钟前,我遇到了同样的问题,然后我找到了CAPTURE,它成功了:

    首先在cqlsh上开始捕获,然后运行您的查询,并限制您的选择。

    http://www.datastax.com/documentation/cql/3.0/cql/cql_reference/capture_r.html

        4
  •  0
  •   user3111988    9 年前

    导出数据的最佳方式是使用nodetool快照选项。这会立即返回,以后可以恢复。唯一的问题是,此导出是针对每个节点和整个集群的。

    例子: nodetool-h localhost-p 7199快照

    参见参考资料: http://docs.datastax.com/en/archived/cassandra/1.1/docs/backup_restore.html#taking-a-snapshot