Cassandra ドキュメント

バージョン

プレリリース版のドキュメントを表示しています。

sstabledump

指定されたSSTableの内容をJSON形式で標準出力にダンプします。

正確に1つのSSTableを指定する必要があります。

このツールを実行する前にCassandraを停止する必要があります。そうでない場合、予期しない結果が発生します。注意:このスクリプトはCassandraが停止していることを検証しません。

使用方法

sstabledump <options> <sstableファイルパス>

-d

行ごとのCQL内部表現

-e

パーティションキーのみ列挙

-k <arg>

パーティションキー

-x <arg>

除外するパーティションキー

-t

iso8601日付文字列ではなく、生のタイムスタンプを出力

-l

各行を個別のJSONオブジェクトとして出力

必要に応じて、最初にsstableutilを使用して、テーブルで使用されているSSTableを確認してください。

テーブル全体のダンプ

オプションなしでテーブル全体をダンプします。

sstabledump /var/lib/cassandra/data/keyspace/eventlog-65c429e08c5a11e8939edf4f403979ef/mc-1-big-Data.db > eventlog_dump_2018Jul26

cat eventlog_dump_2018Jul26
[
  {
    "partition" : {
      "key" : [ "3578d7de-c60d-4599-aefb-3f22a07b2bc6" ],
      "position" : 0
    },
    "rows" : [
      {
        "type" : "row",
        "position" : 61,
        "liveness_info" : { "tstamp" : "2018-07-20T20:23:08.378711Z" },
        "cells" : [
          { "name" : "event", "value" : "party" },
          { "name" : "insertedtimestamp", "value" : "2018-07-20 20:23:08.384Z" },
          { "name" : "source", "value" : "asdf" }
        ]
      }
    ]
  },
  {
    "partition" : {
      "key" : [ "d18250c0-84fc-4d40-b957-4248dc9d790e" ],
      "position" : 62
    },
    "rows" : [
      {
        "type" : "row",
        "position" : 123,
        "liveness_info" : { "tstamp" : "2018-07-20T20:23:07.783522Z" },
        "cells" : [
          { "name" : "event", "value" : "party" },
          { "name" : "insertedtimestamp", "value" : "2018-07-20 20:23:07.789Z" },
          { "name" : "source", "value" : "asdf" }
        ]
      }
    ]
  },
  {
    "partition" : {
      "key" : [ "cf188983-d85b-48d6-9365-25005289beb2" ],
      "position" : 124
    },
    "rows" : [
      {
        "type" : "row",
        "position" : 182,
        "liveness_info" : { "tstamp" : "2018-07-20T20:22:27.028809Z" },
        "cells" : [
          { "name" : "event", "value" : "party" },
          { "name" : "insertedtimestamp", "value" : "2018-07-20 20:22:27.055Z" },
          { "name" : "source", "value" : "asdf" }
        ]
      }
    ]
  }
]

より扱いやすい形式でのテーブルのダンプ

-lオプションを使用して、各行を個別のJSONオブジェクトとしてダンプします。これにより、大規模なデータセットの処理が容易になります。 ref: issues.apache.org/jira/browse/CASSANDRA-13848

sstabledump /var/lib/cassandra/data/keyspace/eventlog-65c429e08c5a11e8939edf4f403979ef/mc-1-big-Data.db -l > eventlog_dump_2018Jul26_justlines

cat eventlog_dump_2018Jul26_justlines
[
  {
    "partition" : {
      "key" : [ "3578d7de-c60d-4599-aefb-3f22a07b2bc6" ],
      "position" : 0
    },
    "rows" : [
      {
        "type" : "row",
        "position" : 61,
        "liveness_info" : { "tstamp" : "2018-07-20T20:23:08.378711Z" },
        "cells" : [
          { "name" : "event", "value" : "party" },
          { "name" : "insertedtimestamp", "value" : "2018-07-20 20:23:08.384Z" },
          { "name" : "source", "value" : "asdf" }
        ]
      }
    ]
  },
  {
    "partition" : {
      "key" : [ "d18250c0-84fc-4d40-b957-4248dc9d790e" ],
      "position" : 62
    },
    "rows" : [
      {
        "type" : "row",
        "position" : 123,
        "liveness_info" : { "tstamp" : "2018-07-20T20:23:07.783522Z" },
        "cells" : [
          { "name" : "event", "value" : "party" },
          { "name" : "insertedtimestamp", "value" : "2018-07-20 20:23:07.789Z" },
          { "name" : "source", "value" : "asdf" }
        ]
      }
    ]
  },
  {
    "partition" : {
      "key" : [ "cf188983-d85b-48d6-9365-25005289beb2" ],
      "position" : 124
    },
    "rows" : [
      {
        "type" : "row",
        "position" : 182,
        "liveness_info" : { "tstamp" : "2018-07-20T20:22:27.028809Z" },
        "cells" : [
          { "name" : "event", "value" : "party" },
          { "name" : "insertedtimestamp", "value" : "2018-07-20 20:22:27.055Z" },
          { "name" : "source", "value" : "asdf" }
        ]
      }
    ]
  }

キーのみのダンプ

-eオプションを使用して、キーのみをダンプします。

sstabledump /var/lib/cassandra/data/keyspace/eventlog-65c429e08c5a11e8939edf4f403979ef/mc-1-big-Data.db -e > eventlog_dump_2018Jul26_justkeys

cat eventlog_dump_2018Jul26b
[ [ "3578d7de-c60d-4599-aefb-3f22a07b2bc6" ], [ "d18250c0-84fc-4d40-b957-4248dc9d790e" ], [ "cf188983-d85b-48d6-9365-25005289beb2" ]

単一キーの行のダンプ

-kオプションを使用して、単一キーをダンプします。

sstabledump /var/lib/cassandra/data/keyspace/eventlog-65c429e08c5a11e8939edf4f403979ef/mc-1-big-Data.db -k 3578d7de-c60d-4599-aefb-3f22a07b2bc6 > eventlog_dump_2018Jul26_singlekey

cat eventlog_dump_2018Jul26_singlekey
[
  {
    "partition" : {
      "key" : [ "3578d7de-c60d-4599-aefb-3f22a07b2bc6" ],
      "position" : 0
    },
    "rows" : [
      {
        "type" : "row",
        "position" : 61,
        "liveness_info" : { "tstamp" : "2018-07-20T20:23:08.378711Z" },
        "cells" : [
          { "name" : "event", "value" : "party" },
          { "name" : "insertedtimestamp", "value" : "2018-07-20 20:23:08.384Z" },
          { "name" : "source", "value" : "asdf" }
        ]
      }
    ]
  }

行のダンプでのキーの除外

-xオプションで除外された行を除いて、テーブルをダンプします。複数のキーを使用できます。

sstabledump /var/lib/cassandra/data/keyspace/eventlog-65c429e08c5a11e8939edf4f403979ef/mc-1-big-Data.db -x 3578d7de-c60d-4599-aefb-3f22a07b2bc6 d18250c0-84fc-4d40-b957-4248dc9d790e  > eventlog_dump_2018Jul26_excludekeys

cat eventlog_dump_2018Jul26_excludekeys
[
  {
    "partition" : {
      "key" : [ "cf188983-d85b-48d6-9365-25005289beb2" ],
      "position" : 0
    },
    "rows" : [
      {
        "type" : "row",
        "position" : 182,
        "liveness_info" : { "tstamp" : "2018-07-20T20:22:27.028809Z" },
        "cells" : [
          { "name" : "event", "value" : "party" },
          { "name" : "insertedtimestamp", "value" : "2018-07-20 20:22:27.055Z" },
          { "name" : "source", "value" : "asdf" }
        ]
      }
    ]
  }

生のタイムスタンプの表示

デフォルトでは、日付はiso8601日付形式で表示されます。-tオプションを使用すると、生のタイムスタンプを使用してデータをダンプします。

sstabledump /var/lib/cassandra/data/keyspace/eventlog-65c429e08c5a11e8939edf4f403979ef/mc-1-big-Data.db -t -k cf188983-d85b-48d6-9365-25005289beb2 > eventlog_dump_2018Jul26_times

cat eventlog_dump_2018Jul26_times
[
  {
    "partition" : {
      "key" : [ "cf188983-d85b-48d6-9365-25005289beb2" ],
      "position" : 124
    },
    "rows" : [
      {
        "type" : "row",
        "position" : 182,
        "liveness_info" : { "tstamp" : "1532118147028809" },
        "cells" : [
          { "name" : "event", "value" : "party" },
          { "name" : "insertedtimestamp", "value" : "2018-07-20 20:22:27.055Z" },
          { "name" : "source", "value" : "asdf" }
        ]
      }
    ]
  }

出力における内部構造の表示

内部構造を反映した形式でテーブルをダンプします。

sstabledump /var/lib/cassandra/data/keyspace/eventlog-65c429e08c5a11e8939edf4f403979ef/mc-1-big-Data.db -d > eventlog_dump_2018Jul26_d

cat eventlog_dump_2018Jul26_d
[3578d7de-c60d-4599-aefb-3f22a07b2bc6]@0 Row[info=[ts=1532118188378711] ]:  | [event=party ts=1532118188378711], [insertedtimestamp=2018-07-20 20:23Z ts=1532118188378711], [source=asdf ts=1532118188378711]
[d18250c0-84fc-4d40-b957-4248dc9d790e]@62 Row[info=[ts=1532118187783522] ]:  | [event=party ts=1532118187783522], [insertedtimestamp=2018-07-20 20:23Z ts=1532118187783522], [source=asdf ts=1532118187783522]
[cf188983-d85b-48d6-9365-25005289beb2]@124 Row[info=[ts=1532118147028809] ]:  | [event=party ts=1532118147028809], [insertedtimestamp=2018-07-20 20:22Z ts=1532118147028809], [source=asdf ts=1532118147028809]