I have all keyspaces and tables copied from another cassandara data folder ,How can I restore it in my cassandara node.
I dont have snapshots which are normally required to restore.
I have all keyspaces and tables copied from another cassandara data folder ,How can I restore it in my cassandara node.
I dont have snapshots which are normally required to restore.
You might be able to do this with the Cassandra Bulk Loader.
Assuming a packaged install (with default data and bin locations), try this from one of your nodes:
$ sstableloader -d hostname1,hostname2 /var/lib/cassandra/data/yourKeyspaceName/tableName/
Check out the documentation on the Bulk Loader for more details.
You can do this but:
You need to know the schema for all the tables you are restoring. If you don't know this, use sstable2json (example below, but this can be tricky and requires understanding how sstable2json formats things)
You will have to start a new node, create the keyspace and it's tables using the schema derived from 1 and then use the BulkLoader as described in the docs by Aaron (BryceAtNetwork23).
Example of retreiving a schema (an offline process) using sstable2json, this example assumes your keyspace name is test and the table is named 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]]}
]
The above equates to:
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';
You can see clearly that username and password get lost in the translation as they are the key, but you can tell that there is a compound key based on the fact that all cells have a section with : pre-appended, in the above two entries the examples are coolguy: and lyubent:. Going on this you know that they key is formed of PRIMARY KEY(something ?, username text). If you're lucky your primary key will be simple and debugging the schema from it will be straight forward, if not post it here and we'll see how far we can get.