Tuesday, January 3, 2023

How to migrate the data between AWS Redshift clusters ? or steps to configure the datashare in aws Redshift cluster?

 pre-request:

******************


get the cluster_name_space of source & Target cluster.



[source_cluster_name_space]==>source_DB


[target_cluster_name_space]==>Target_DB


source_cluster (Producer)

**********************


 create datashare Data_share_copy_source_2_target publicaccessible=false; --create Datashare


 alter datashare Data_share_copy_source_2_target add schema  schema_name; --- add schema to migrate the tables


 alter datashare Data_share_copy_source_2_target set includenew=true for schema schema_name;--add future object


 alter datashare Data_share_copy_source_2_target add all tables  in  schema schema_name;--current objects



 grant usage on datashare Data_share_copy_source_2_target to namespace '[target_cluster_name_space]';




Target_cluster (consumer)

********************


--create new datashare  to import the data to current/target cluster


create database import_DS_target from datashare Data_share_copy_source_2_target of  namespace '[source_cluster_name_space]';


--copy the data from imported Datashare  to  target DB tables


Move data  from source to Target:

***************************

create the empty table1 with same structure on target DB and insert the data.

insert into schema_name.table1 select * from  Data_share_copy_source_2_target.schema_name.table1