Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrate data from cassandra to cassandra

We have 2 cassandra clusters, first one has the old data and second one has the new data.

Now we want to move or copy the old data from first cluster to second. What is the best way to do this and how to do this?

we are using DSE 3.1.4.

like image 778
Ram Avatar asked Nov 15 '13 13:11

Ram


People also ask

How do I migrate data to Cassandra?

Database Migration using Cassandra Datacenter SwitchRestrict traffic to the existing datacenter. Expand the Cassandra cluster by adding a new datacenter in a Kubernetes cluster using K8ssandra. Rebuild the newly created datacenter. Switch traffic over to the K8ssandra datacenter.

How do I import data into Cassandra database?

If you have data in a file so, you can directly insert your data into the database by using the COPY command in Cassandra. It will be very useful when you have a very large database, and you want to store data quickly and your data is in a CSV file then you can directly insert your data.

What is Sstableloader in Cassandra?

Provides the ability to bulk load external data into a cluster, load existing SSTables into another cluster with a different number of nodes or replication strategy, and restore snapshots.


2 Answers

One tool you could try would be the COPY TO/FROM cqlsh command.

On a node in the old cluster, you would use the COPY TO:

cqlsh> COPY myTable (col1, col2, col3, col4) TO 'temp.csv'

And then (after copying the file over) on a node in your new cluster, you would copy the data in the CSV file into Cassandra:

cqlsh> COPY myTable (col1, col2, col3, col4) FROM 'temp.csv'

Here is some more documentation on the COPY command.

Note that the COPY TO/FROM is recommended for tables that contain only a few million rows or less. For larger datasets you should look at:

  • Cassandra Bulk Loader
  • sstable2json
like image 128
Aaron Avatar answered Sep 29 '22 21:09

Aaron


There is a tool called /usr/bin/sstableloader for copying data between the clusters. Although when I used it months ago, I encountered an error and used this instead. But since it was a long time ago, sstableloader might have been fixed already.

like image 35
Roman Tumaykin Avatar answered Sep 29 '22 21:09

Roman Tumaykin