Steps taken in Existing Cassandra Cluster. ===========================
1) Take snapshot of keyspace, backup schema and also copy backups folder under keyspace directory if incremental backup is enabled in the existing cluster. Take a snapshot of keyspace. ============================ nodetool snapshot -t my_snapshot_tag Backup keyspace schema ====================== echo -e "use your_keyspace;\r\n show schema;\n" | bin/cassandra-cli -h localhost > mySchema.cdl Copy backups folder under keyspace ================================== tar -cvzf backups.tar.gz /var/lib/cassandra/data/keyspace_name/backups 2) Note the token enabled in the existing cluster ./nodetool ring -h localhost Address DC Rack Status State Load Owns Token 85070591730234615865843651857942052863 193.41.xx.xx datacenter1 rack1 Up Normal 2.24 GB 50.00% 1 193.41.xx.yy datacenter1 rack1 Up Normal 2.18 GB 50.00% 85070591730234615865843651857942052863 Here the token enabled in node1 is 85070591730234615865843651857942052863 and node2 is 1 Steps to do in New Cassandra Cluster ============================== 1) Stop cassandra cluster kill -9 <cassandra process> 2) Delete system keyspace data files rm -rf /var/lib/cassandra/data/system/ a) delete commit_log (var/lib/cassandra/commitlog) b) saved_cache (/var/lib/cassandra/saved_caches) c) clear contents in /var/lib/cassandra/data/<keyspace> 3) Disable auto_bootstrap to false in cassandra.yaml auto_bootstrap: false 4) Put initial_token with the values as same as that in existing cluster to cassandra.yaml (noted values in step2 of exisiting cluster) 5) Make sure that below parameter is false in cassandra-env.sh JVM_OPTS="$JVM_OPTS -Dcassandra.load_ring_state=false If there is no entry, please leave as it is. 6) Start the cluster and run below command. ./nodetool ring -h localhost Make sure that token is showing as same as that of existing cluster 7) Restore the schema file in node1 from existing cluster. bin/cassandra-cli -h localhost -f mySchema.cdl Make sure that the same schema is loaded in node2 automatically, otherwise restore it in node2 as well. 8) Stop the cluster and restore data. a) Locate the most recent snapshot folder in <data_directory_location>/<keyspace_name>/snapshots/<snapshot_name>, and copy its contents into <data_directory_location>/<keyspace_name>. b) If using incremental backups as well, copy all contents of <data_directory_location>/<keyspace_name>/backups into <data_directory_location>/<keyspace_name>. 9) Start cassandra and refresh tables again. for x in `cat /root/cassandra/webax_tables.txt`; do ./nodetool -h localhost refresh webax_ekp_staging $x;done; That's it.
Monday, 20 March 2017
Cassandra Migration(Version 1.X)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment