【问题标题】:Cassandra CQL clone keyspace schemaCassandra CQL 克隆键空间模式
【发布时间】:2013-04-01 20:54:47
【问题描述】:

我正在尝试转储 Cassandra 键空间的架构,该架构可用于将其导入另一个键空间,例如备份 cassandra 键空间并将其恢复到具有相同架构的不同键空间。

我正在使用 cqlsh:

[cqlsh 2.3.0 | Cassandra 1.2.2 | CQL spec 3.0.1 | Thrift protocol 19.35.0]

我最初使用 CLUSTERING ORDER 时间戳 DESCENDING 顺序创建架构:

DROP KEYSPACE mailbox;

CREATE KEYSPACE mailbox 
    WITH REPLICATION  = { 'class': 'SimpleStrategy', 'replication_factor': '1' };

USE mailbox;

CREATE TABLE messages (
    id uuid,
    user_id uuid,
    contents varchar,
    created timestamp,

    PRIMARY KEY (id, created)
)
WITH CLUSTERING ORDER BY (created DESC);

然后我使用 CQL 函数转储我认为有效的 CQL3:

cqlsh:mailbox> describe keyspace mailbox;

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

USE mailbox;

CREATE TABLE messages (
  id uuid,
  created 'org.apache.cassandra.db.marshal.ReversedType'<timestamp>,
  contents text,
  user_id uuid,
  PRIMARY KEY (id, created)
) WITH
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=864000 AND
  read_repair_chance=0.100000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={'sstable_compression': 'SnappyCompressor'};

当我尝试将其导入 cqlsh 时,我收到以下错误:

Bad Request: line 3:56 mismatched input '<' expecting ')'
text could not be lexed at line 16, char 14

我认为它无法解析创建的列定义(最初是使用 CLUSTERING ORDER BY 创建的):

created 'org.apache.cassandra.db.marshal.ReversedType'<timestamp>

还有其他方法可以转储给定键空间的架构吗?

【问题讨论】:

    标签: schema cassandra datastore cql cql3


    【解决方案1】:

    嗯.. 认为这个问题在 cassandra 1.2.5 中得到了解决,并且您正在使用 cassandra 1.2.2 https://issues.apache.org/jira/browse/CASSANDRA-5528 并且更好的是,升级到 cassandra 2.0 因为在这里进行了测试,它在 cassandra 2.0.2 中运行良好。

    作为旁注,您可能还需要关注 cql 版本。 http://cassandra.apache.org/doc/cql3/CQL.html#Versioning

    【讨论】:

      猜你喜欢
      • 2021-11-25
      • 2014-05-29
      • 2017-05-19
      • 1970-01-01
      • 2015-12-18
      • 1970-01-01
      • 2012-07-25
      • 2021-09-12
      • 1970-01-01
      相关资源
      最近更新 更多