我正在尝试转储 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>
是否有其他方法可以转储给定键空间的模式?