我从另一个cassandra数据文件夹中复制了所有键空间和表格,如何在我的cassandra节点中恢复它。
我没有通常需要恢复的快照。
答案 0 :(得分:3)
您可以使用Cassandra Bulk Loader执行此操作。
假设打包安装(包含默认数据和bin位置),请从您的一个节点尝试此操作:
$ sstableloader -d hostname1,hostname2 /var/lib/cassandra/data/yourKeyspaceName/tableName/
答案 1 :(得分:2)
你可以这样做但是:
您需要知道要还原的所有表的架构。如果您不知道这一点,请使用sstable2json(下面的示例,但这可能很棘手,需要了解sstable2json如何格式化事物)
您必须启动一个新节点,使用派生自1的模式创建密钥空间及其表,然后按照Aaron(BryceAtNetwork23)文档中的描述使用BulkLoader。
使用sstable2json检索模式(脱机进程)的示例,此示例假定您的键空间名称为 test ,表名为 example1 :
sstable2json /var/lib/cassandra/data/test/example1-55639910d46a11e4b4335dbb0aaeeb24/test-example1-ka-1-Data.db
// output:
WARN 10:25:34 JNA link failure, one or more native method will be unavailable.
[
{"key": "7d700500-d46b-11e4-b433-5dbb0aaeeb24", <-- key = bytes of what is in the PRIMARY KEY()
"cells": [["coolguy:","",1427451885901681], <-- cql3 row marker (empty cell that tells us table was created using cql3)
["coolguy:age","29",1427451885901681], <-- age
["coolguy:email:_","coolguy:email:!",1427451885901680,"t",1427451885], <-- collection cell marker
["coolguy:email:6367406d61696c2e6e6574","",1427451885901681], <-- first entry in collection
["coolguy:email:636f6f6c677579383540676d61696c2e636f6d","",1427451885901681], <-- second entry in collection
["coolguy:password","xQajKe2fa?af",1427451885901681]]}, <-- another text field for password
{"key": "52641f40-d46b-11e4-b433-5dbb0aaeeb24",
"cells": [["lyubent:","",1427451813663728],
["lyubent:age","109",1427451813663728],
["lyubent:email:_","lyubent:email:!",1427451813663727,"t",1427451813],
["lyubent:email:66616b65406162762e6267","",1427451813663728],
["lyubent:email:66616b6540676d61696c2e636f6d","",1427451813663728],
["lyubent:password","password",1427451813663728]]}
]
以上等同于:
CREATE TABLE test.example1 (
id timeuuid,
username text,
age int,
email set<text>,
password text,
PRIMARY KEY (id, username)
) WITH CLUSTERING ORDER BY (username ASC)
// the below are settings that you have no way of knowing,
// unless you are hardcore enough to start digging through
// system tables with the debug tool, but this is beyond
// the scope of the question.
AND bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = ''
AND compaction = {'min_threshold': '4', 'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32'}
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99.0PERCENTILE';
您可以清楚地看到用户名和密码在翻译中丢失,因为它们是关键,但您可以根据以下事实判断出复合键:所有单元格都有一个部分:预先附加,在以上两个条目的例子是coolguy:和lyubent:继续这个你知道他们的密钥是由PRIMARY KEY(东西?,用户名文本)组成的。如果您很幸运,您的主键很简单,并且从中调试架构将是直截了当的,如果不在此处发布,我们将看到我们能走多远。