【问题标题】:cassandra-cli 'list' in cassandra 3.0cassandra 3.0 中的 cassandra-cli 'list'
【发布时间】:2016-06-27 00:25:51
【问题描述】:

我想在 cassandra 3.0 中查看“行键”及其存储的数据。我知道,贬值的 cassandra-cli 有“列表”命令。但是,在 cassandra 3.0 中,我找不到“list”命令的替代品。有人知道'list' 的新cli 命令吗?

【问题讨论】:

  • SELECT * FROM table 在 cqlsh 中。单元格不再像 thrift 格式那样布置在磁盘上,因此 CQL SELECT 代表您的数据。
  • 但我想看看 Cassandra 是如何在后台存储这些数据的。 “从表中选择 *”没有向我显示以下格式:RowKey: 100. => (name=, value=, timestamp=1387..) 07. => (name=tmp, value=51cc0000, timestamp= 1387...)。 cassandra 是如何将我的“select * from table”存储在引擎盖下的?我不能再在 cassandra 3 中使用“列表”了。
  • 如果真的想深入了解它的存储方式,您可以使用 sstabledump 实用程序(-d 选项更紧凑的阅读)。更多交互可以使用sstable tools中的cqlsh离线功能

标签: cassandra cassandra-cli


【解决方案1】:

您可以按照@chris-lohfink 的建议使用sstabledump 实用程序。如何使用它?创建键空间,其中的表填充一些数据:

cqlsh> CREATE KEYSPACE IF NOT EXISTS minetest WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };

cqlsh> CREATE TABLE object_coordinates (
   ... object_id int PRIMARY KEY,
   ... coordinate text
   ... );

cqlsh> use minetest;

cqlsh:minetest> insert into object_coordinates (object_id, coordinate) values (564682,'59.8505,34.0035');
cqlsh:minetest> insert into object_coordinates (object_id, coordinate) values (1235,'61.7814,40.3316');
cqlsh:minetest> select object_id, coordinate, writetime(coordinate) from object_coordinates;

 object_id | coordinate      | writetime(coordinate)
-----------+-----------------+-----------------------
      1235 | 61.7814,40.3316 |      1480436931275615
    564682 | 59.8505,34.0035 |      1480436927707627

(2 rows)

object_id 是主(分区键)键,coordinate 是集群键。

将更改刷新到磁盘:

# nodetool flush

在磁盘上找到 sstable 并分析它:

# cd /var/lib/cassandra/data/minetest/object_coordinates-e19d4c40b65011e68563f1a7ec2d3d77

# ls
backups  mc-1-big-CompressionInfo.db  mc-1-big-Data.db  mc-1-big-Digest.crc32  mc-1-big-Filter.db  mc-1-big-Index.db  mc-1-big-Statistics.db  mc-1-big-Summary.db  mc-1-big-TOC.txt

# sstabledump mc-1-big-Data.db
[
  {
    "partition" : {
      "key" : [ "1235" ],
      "position" : 0
    },
    "rows" : [
      {
        "type" : "row",
        "position" : 18,
        "liveness_info" : { "tstamp" : "2016-11-29T16:28:51.275615Z" },
        "cells" : [
          { "name" : "coordinate", "value" : "61.7814,40.3316" }
        ]
      }
    ]
  },
  {
    "partition" : {
      "key" : [ "564682" ],
      "position" : 43
    },
    "rows" : [
      {
        "type" : "row",
        "position" : 61,
        "liveness_info" : { "tstamp" : "2016-11-29T16:28:47.707627Z" },
        "cells" : [
          { "name" : "coordinate", "value" : "59.8505,34.0035" }
        ]
      }
    ]
  }
]

或使用-d 标志:

# sstabledump mc-1-big-Data.db -d
[1235]@0 Row[info=[ts=1480436931275615] ]:  | [coordinate=61.7814,40.3316 ts=1480436931275615]
[564682]@43 Row[info=[ts=1480436927707627] ]:  | [coordinate=59.8505,34.0035 ts=1480436927707627

输出表明1235564682 并将坐标保存在这些分区中。

链接到文档http://www.datastax.com/dev/blog/debugging-sstables-in-3-0-with-sstabledump

PS。 sstabledump 由 ubuntu 中的 cassandra-tools 包提供。

【讨论】:

    猜你喜欢
    • 2019-04-10
    • 2012-07-23
    • 2012-09-18
    • 1970-01-01
    • 2017-08-29
    • 1970-01-01
    • 2018-04-24
    • 2013-08-14
    • 2016-12-23
    相关资源
    最近更新 更多