2

我正在尝试使用 sstable2json 从 cassandra 导出数据,但是当我尝试运行命令时

sstable2json /var/lib/cassandra/data/S2B_development/users-g-110-Data.db

发生错误

log4j:WARN No appenders could be found for logger (org.apache.cassandra.config.DatabaseDescriptor). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. no non-system tables are defined Exception in thread "main" org.apache.cassandra.config.ConfigurationException: no non-system tables are defined at org.apache.cassandra.tools.SSTableExport.main(SSTableExport.java:414)

卡桑德拉版本:0.8

4

1 回答 1

2

如何从 sstable2json 获取输出的示例

为了其他开发者的利益:

1.启动 Cassandra
2.启动 cqlsh
3.创建一个键空间:

CREATE KEYSPACE test WITH replication = 
    {'class': 'SimpleStrategy', 'replication_factor': 1};

4.创建一个CF

CREATE TABLE test.test2
(
  key varchar PRIMARY KEY, 
  string varchar, 
  number int, 
  flag boolean
);

5.用一个键(或很多键...)填充 CF

INSERT INTO test.test2 (key, string, number, flag)
VALUES ('first_key', 'varchuuur', 312, false);

6.刷新数据(因此它从 memtable 保存到 sstable)
7.停止 Cassandra
8.运行 sstable2json

./bin/sstable2json /var/lib/cassandra/data/test/test2/test-test2-jb-1-Data.db;

输出:

[
  {
    "key": "66697273745f6b6579","columns": 
    [
      ["","",1378042590383000], 
      ["flag","true",1378042590383000], ["number","312",1378042590383000], 
      ["string","varchuuur",1378042590383000]
    ]
  }
]
于 2013-09-17T13:25:34.070 回答