cassandra migration table data

 

  There are 2 ways to migrate table data in cassandra. Take keyspace named mydb and table named user as examples:

Method one: copy command.

  This method is suitable for the case where the amount of data is small.
  1. Enter cqlsh and enter the command: COPY mydb.user TO '/usr/usr.scv';

  


  2. Find the usr.scv file just generated and copy it to the server that needs to be migrated

  


  3. In the migrated data table user (the table structure is the same), and then enter COPY mydb.user FROM '/usr/user.scv'; Note: The key space here can be different
  

  At this point, the first way is over, this way is suitable for the case of a small amount of data.
 

Method 2: sstableloader
  
sstableloader provides a solution that can migrate data across clusters, reference materials http://docs.datastax.com/en/cassandra/3.0/cassandra/tools/toolsBulkloader.html.
  In this way, the same key space and table structure need to be built in the migrated database .
  Use 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: migrated cluster user Name; -pw: user password of the migration cluster; -t: restrict traffic; the last is the directory where the migrated cluster stores data (/.../keyspace_name/table_name).   Note:     1. If the cluster has multiple nodes, each node needs to execute the above command     2. Sometimes a table will have multiple directories     as shown in the above picture. In this case, the final path is to select the path containing the .db file in the directory (Latest table)
  
  




    


    

    After all the nodes in the cluster are executed, the migration of the table data is completed.

Published 19 original articles · praised 4 · 170,000 views +

Guess you like

Origin blog.csdn.net/u011250186/article/details/105635253