Cassandra CQL克隆键空间架构

时间:2013-04-01 20:54:47

标签: schema cassandra datastore cql cql3

我正在尝试转储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>

是否有其他方法可以转储给定键空间的模式?

1 个答案:

答案 0 :(得分:0)

嗯...认为这个问题在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