There are 2 ways to migrate table data in Cassandra, with Keyspace named user mydb,table as an example:
Method one: Copy command.
This approach is suitable for situations where the amount of data is small.
1. Enter Cqlsh, input command: COPY mydb.user to '/USR/USR.SCV ';
2. Locate the USR.SCV file that you just generated and copy it to the server that you want to migrate
3. In the Migrated data table user (the table structure is the same), and then enter the COPY mydb.user from '/USR/USER.SCV '; Note: Here the key space can be different
By the end of the first approach, this approach is suitable for situations where data volumes are small.
Method Two: Sstableloader
Sstableloader provides a solution for migrating data across a cluster, reference http://docs.datastax.com/en/cassandra/3.0/cassandra/tools/toolsBulkloader.html.
In this way, you need to build the same key space and table structure in the migrated database .
Using the command:./sstableloader-d 192.168.3.90-u CASSANDRA-PW cassandra-t 100/var/lib/cassandra/data/mydb/ user-77470310dc9111e6b83b3767ed5523d2/
-D: Migrated server ip;-u: The user name of the migrated cluster,-PW: User password for migrating the cluster,-T: Limit traffic, and finally the directory (/.../keyspace_name/table_name) in which the cluster is being migrated to store data.
Note:
1. If the cluster has multiple nodes, each node needs to execute the above command
2. Sometimes a table will have multiple catalogs
In this case, the final path is to select the path to the directory that contains the. db file (the latest table)
When all nodes of the cluster are executed, the migration of the table data is completed.
Cassandra Migrating table Data