I created an old keyspace in Cassandra cluster but found the definition of its "comparator" is wrong, so I have to recreate a new keyspace and do data migration. Is there any tool to do data migration? or I have to program with Thrift client read all data from old keyspace and write them to new keyspace? Any suggestions or code snippets is welcome!
This is a commun question, and I think it has been asked before here.
You can use the COPY
command in C*.
You will find more details here http://www.datastax.com/dev/blog/ways-to-move-data-tofrom-datastax-enterprise-and-cassandra
We can do it using COPY
command in cql. Using COPY
command we can save table data to .csv file and back to a table from .csv file. But, the better approach will be to write a program to read from table and write it to another table because importing from csv may fail if the table contains collection column types like list<text>
, map<text, text>
, set<text>
.
Eg :- To copy table data from table to .csv file :-
COPY keyspace1.table1 (column1, column2) TO 'path/to/file/keyspace1_table1.csv';
To copy csv data from file to a table :-
COPY keyspace2.table1 (column1, column2) FROM 'path/to/file/keyspace1_table1.csv';
Refer Cassandra migration tool
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With