Before migrating data with MaxCompute Migration Service (MMS), you need to create and start a Redshift data source, ensure network connectivity between the data source and MMS, and sync the Redshift metadata to MMS. This prepares the service for you to configure migration jobs.
Scope
Amazon Redshift in cluster and serverless modes.
Full data migration.
Billing
MMS data migration incurs costs by consuming various resources. The following table outlines the main cost components.
MMS operation | Billable item | Billed by |
Data source operations (including metadata synchronization) | compute cost: Applies when system table queries run on AWS Redshift.
| AWS Redshift |
Data migration during a job run | compute cost: Spark jobs that run on MaxCompute consume compute resources. | Alibaba Cloud MaxCompute |
UNLOAD from AWS Redshift to Amazon Simple Storage Service (S3) | storage cost: Applies to data stored in a temporary S3 directory. | AWS |
MaxCompute reads data from S3 | data transfer fee: Applies to data egress from S3. | AWS |
If data validation is enabled for the migration job | compute cost: Applies when validation SQL statements run on both AWS Redshift and MaxCompute. | Alibaba Cloud MaxCompute and AWS Redshift |
Network configuration | Network costs:
| Your dedicated line provider or AWS |
To reduce migration costs, we recommend using subscription compute resources and dedicated data transfer resources for your migration jobs.
Procedure
Ensure that the destination MaxCompute project is prepared.
Step 1: Prepare the external data source
To read data from Redshift, complete the preparations in the following table. See the steps below for detailed instructions.
Preparation item | Description |
Redshift cluster or serverless workgroup | Ensure that it is created and available. |
JDBC connection URL | Enables MMS to connect to Redshift. |
Network and security group | Ensure that MMS can access Redshift across clouds. |
AWS Access Key | Allows MaxCompute Spark to read temporary data from S3. |
S3 bucket | Stores temporary data during the migration process. |
IAM role | Authorizes Redshift to write to S3 by using the UNLOAD command. The role must be associated with the cluster or namespace. |
Database user permissions | Permissions to read system tables and migration tables, and write to S3. |
Ensure that the Redshift cluster or serverless workgroup is created and available.
Get the JDBC connection URL
Get the JDBC connection URL for Redshift. You will need this URL when adding the data source in MMS.
Cluster mode format:
jdbc:redshift://cluster-name.xxx.redshift.amazonaws.com:5439/Serverless mode format:
jdbc:redshift://xxx.redshift-serverless.amazonaws.com:5439/
Configure network and security groups
MMS is an Alibaba Cloud service. To access AWS Redshift across clouds, you must ensure network connectivity.
The simplest method is to enable public access from MMS to AWS Redshift, as shown in the following example:
Ensure that your Redshift instance is configured to be publicly accessible.
Add the egress IP address CIDR blocks of MMS to the security group inbound rule associated with your Redshift instance.
The following is an example of a security group inbound rule for public access:
Type
Port
Source
Description
Redshift
5439
MMS egress IP addresses
Allows MMS to access Redshift.
WarningAs a security best practice, open only the necessary IP address ranges. Avoid using 0.0.0.0/0.
Prepare an AWS Access Key
Prepare an AWS Access Key ID and a Secret Access Key with read permissions for S3. MaxCompute Spark uses these credentials to read data from the temporary S3 directory.
The following table lists the minimum required permissions.
Permission
Description
Required
s3:GetObject
Allows reading data files from the temporary S3 directory.
Yes
s3:ListBucket
Allows listing objects in the S3 bucket.
Yes
The following is an example of a policy with the minimum required permissions:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:GetObject", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*" ] } ] }Create an S3 bucket (temporary directory)
Create an S3 bucket to store temporary data during migration.
We recommend that you configure a lifecycle policy to automatically clean up temporary data and reduce storage costs.
Create and associate an IAM role
Create an IAM role that allows Redshift to write to S3, and associate it with your Redshift cluster or serverless configuration.
ImportantThe IAM role must be associated with the Redshift cluster or serverless configuration. Otherwise, the UNLOAD operation fails with the error message
"The requested role is not associated to cluster".Required S3 permissions
Permission
Description
Required
s3:PutObject
Allows Redshift to export data to S3 by using the UNLOAD command.
Yes
s3:GetObject
Allows Redshift to read data from S3.
Yes
s3:ListBucket
Allows MaxCompute Spark to list objects in the S3 bucket.
Yes
Associate the IAM role with Redshift
The association method varies between cluster mode and serverless mode.
Cluster mode
Log on to the AWS Redshift console.
Select the target cluster and click Actions.
Click Manage IAM roles.
Select the IAM role you created, click Associate IAM role, and save the changes.
Serverless mode
Log on to the AWS Redshift console.
In the left-side navigation pane, select Redshift Serverless.
Select Namespaces and click the target namespace.
On the Security and encryption tab, find Permissions.
Click Manage IAM roles, add the IAM role you created, and save the changes.
IAM role configuration examples
Trust policy (allows the Redshift service to assume the role):
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "redshift.amazonaws.com", "redshift-serverless.amazonaws.com" ] }, "Action": "sts:AssumeRole" } ] }Minimum permissions policy (includes only required permissions):
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:PutObject", "s3:GetObject", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*" ] } ] }
Database user permissions
The Redshift database user needs the following permissions:
Permission type
Description
Permissions to read system tables
SELECT permission on system tables such as
pg_class,pg_namespace,pg_attribute,pg_type,pg_constraint, andsvv_redshift_schemas. Regular users have this permission by default.Permissions to read tables
SELECT permission on the tables to be migrated.
Permissions to write to S3
The IAM role authorizes Redshift to write to the temporary S3 directory.
Step 2: Add a data source
Log in to the MaxCompute console and select a region in the upper-left corner.
In the left-side navigation pane, choose .
On the Data Source tab, click Add Data Source.
To create the service-linked role, click OK in the MaxCompute Service-linked Role dialog box. If this dialog box does not appear, the role already exists.
On the Add Data Source page, configure the data source and click Add.
Data Source Basic Information
Parameter
Required
Description
Data Source Name
Yes
The custom name for the data source. The name can only contain letters and digits.
Data Source Type
Yes
Select Redshift.
Network Connection
Yes
Select the network connection to use.
Network connections are created in the MaxCompute module and allow MMS to communicate with the VPC and connect to the data source.
AWS Access Key ID
Yes
The ID of your AWS access key. MaxCompute Spark uses this key to read migration data from the temporary S3 directory. For information about how to obtain an access key, see Creating access keys for an IAM user.
AWS Secret Access Key
Yes
The secret for your AWS access key. Used with the AWS Access Key ID, this secret allows MaxCompute Spark to access the temporary S3 directory.
Redshift JDBC URL
Yes
The JDBC connection URL for Redshift, without the database name, username, or password. Format:
jdbc:redshift://endpoint:5439/.Cluster mode example:
jdbc:redshift://cluster-name.xxx.redshift.amazonaws.com:5439/.Serverless mode example:
jdbc:redshift://xxx.redshift-serverless.amazonaws.com:5439/.
Redshift Database Name
Yes
The name of the Redshift database.
Redshift Username
Yes
The username for the Redshift database.
Redshift Password
Yes
The password for the Redshift database. MMS uses the password to connect to Redshift, get metadata (such as table schemas, column information, and constraints), and run UNLOAD operations to export data to S3.
S3 Temporary Directory Region
No
The AWS region where the temporary S3 directory is located. Specifying the region can prevent cross-region issues and auto-discovery delays. Examples:
us-east-1,us-west-2.S3 Temporary Directory
Yes
The temporary S3 directory used to store data from UNLOAD operations.
Format:
s3a://bucket/path/. After migration, you can configure an S3 lifecycle policy to automatically clean up the temporary data.AWS IAM Role
Yes
The IAM role that Redshift uses to write to S3. Redshift assumes this role to UNLOAD data into the temporary S3 directory.
Format:
arn:aws:iam::account-id:role/role-name.For more information, see Creating IAM roles and the UNLOAD documentation in the AWS documentation.
Default Destination MaxCompute Project
Yes
The target project for data migration. This setting cannot be modified after the data source is created.
Destination MaxCompute Project List
No
If data from a single data source needs to be migrated to multiple destination projects, specify the list of target MaxCompute projects.
Project for running migration jobs
Yes
The project where MaxCompute runs migration jobs, such as Spark and SQL jobs. This project's default computing quota is used.
Other information
The following parameters are optional. Configure them as needed.
Step 3: Sync metadata
After you start the data source, MMS creates a job instance. This instance connects the data source to MMS and synchronizes source metadata to MMS. You need this metadata to configure migration jobs.
This job instance uses 4 CU of compute resources. If no migration or metadata sync jobs are queued or running, MMS shuts down the data source. Restart it before use.
In Redshift Serverless mode, metadata synchronization queries Redshift system tables and incurs query costs. We recommend that you configure a reasonable schedule for metadata updates to control costs.
On the Data Source tab, for the target data source, click Update metadata in the Actions column.
The Data Source tab shows the Status of the target data source.
If metadata changes occur and you enabled metastore scheduled update, MMS updates metadata automatically on schedule. No manual sync is needed.
After you finish configuring the external data source, create a migration job.
Supported data types
Redshift supports a much wider date range (4713 BC to 294276 AD) than MaxCompute (1 AD to 9999 AD).
You cannot migrate tables that contain a column of the
HLLSKETCHdata type. To migrate the table, remove the column or use an alternative approximate distinct counting solution.
Numeric types
Redshift | Alias | MaxCompute | Compatibility |
SMALLINT | INT2 | SMALLINT | Compatible |
INTEGER | INT, INT4 | INT | Compatible |
BIGINT | INT8 | BIGINT | Compatible |
DECIMAL(p,s) | NUMERIC | DECIMAL(p,s) | Compatible |
REAL | FLOAT4 | FLOAT | Compatible |
DOUBLE PRECISION | FLOAT8, FLOAT | DOUBLE | Compatible |
Character types
Redshift | Alias | MaxCompute | Compatibility |
CHAR(n) | CHARACTER, NCHAR | STRING | Compatible |
VARCHAR(n) | CHARACTER VARYING | STRING | Compatible |
TEXT | - | STRING | Compatible |
Date and time types
Redshift | Format/description | MaxCompute | Remarks |
DATE |
| DATE | - |
TIME | without time zone | STRING | MaxCompute does not have a |
TIMETZ | with time zone | STRING | MaxCompute does not have a |
TIMESTAMP | without time zone | TIMESTAMP_NTZ | MaxCompute supports nanosecond precision. |
TIMESTAMPTZ | with time zone | TIMESTAMP | MaxCompute supports nanosecond precision. |
Other types
Redshift | Description | MaxCompute | Remarks |
BOOLEAN | boolean type | BOOLEAN | Compatible |
SUPER | JSON superset type | STRING | MaxCompute does not have a |
VARBYTE(n) | Binary data, up to 16 MB. | BINARY | The maximum size for the |
GEOMETRY | spatial data | STRING | MaxCompute does not have a |
GEOGRAPHY | geographic data | STRING | MaxCompute does not have a |
Usage limits
Limit | Redshift | MaxCompute | Impact |
HLLSKETCH type | Supported | Not supported | Tables with this column type cannot be migrated. Remove the column or use another approximate distinct counting solution. |
VARBYTE length | Up to 16 MB | Up to 8 MB | Preprocess data larger than 8 MB. |
Number of columns | 1,600 | 1,200 | Split tables that exceed the column limit. |
Auto-incrementing column | IDENTITY supported | Not supported | The auto-increment property is not migrated. |
FAQ
Troubleshooting connection issues
JDBC connection failures
Ensure the network connection is configured correctly.
Ensure the JDBC URL format is correct.
Ensure the username and password are correct.
S3 permission issues
Ensure the AWS Access Key has S3 read permissions.
Ensure the IAM Role is correctly associated with the Redshift cluster or serverless namespace.
Ensure the S3 bucket policy allows access.
Performance optimization
S3 temporary directory region
Create the S3 temporary directory in the same region as Redshift to avoid cross-region data transfer.
Explicitly configure the
redshift.tempdir.regionparameter to prevent auto-discovery delays.
S3 lifecycle policy
Configure a lifecycle policy for the S3 temporary directory to automatically delete expired data.
Set temporary files to be automatically deleted after 7 days.