MaxCompute data source
Before you configure migration jobs in MaxCompute Migration Service (MMS), add a data source, ensure network connectivity with MMS, and sync the source metadata.
Migration modes
Data migration between MaxCompute projects supports two modes. Each mode has different permission and network requirements and migration costs.
Same-region migration using SQL
Migration jobs use SQL to read data from and write data to MaxCompute.
Cross-region migration
Using Spark and Open Storage
Migration jobs use Spark to call Open Storage APIs to read and write data.
Using Spark and OSS for transit
The migration task creates an OSS external table in the source project to write data to OSS, uses Spark to directly read the data files from the source OSS directory, and then migrates the data to the destination.
Billing
MMS data migrations consume resources and incur the following costs:
MMS actions | Billable item |
Data source operations, including metadata synchronization. | Compute costs: Generated when a Spark job consumes compute resources. |
same-region migration - Use SQL to migrate data | Compute costs:
|
cross-region migration - Use Spark+open storage |
|
cross-region migration - Use Spark+OSS for data transit |
|
To reduce costs, use subscription compute resources and dedicated data transfer resources for migration jobs.
Procedure
Ensure that the Prerequisites for the destination MaxCompute project are complete.
Step 1: Prepare the source MaxCompute project
Authorize metadata synchronization and data migration
Use the source account to configure metadata synchronization and data migration permissions for the data source.
Metadata synchronization permissions
Create the service-linked role (
AliyunServiceRoleForMaxComputeMMS) for the source MaxCompute project.You must use the source account to create the service-linked role.
If you are using an Alibaba Cloud account, you can create the service-linked role directly.
If you are a RAM user, you must first have the
AliyunRAMFullAccesspermission. For more information, see Manage permissions for a RAM role.You can create the service-linked role in the MaxCompute console or the RAM console.
MaxCompute console
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.
RAM console
Log in to the RAM console.
In the left navigation bar, select .
On the Roles page, click Create Role.
In the upper-right corner of the Create Role page, click Create Service Linked Role.
On the Create Service Linked Role page, under Select Service, select
AliyunServiceRoleForMaxComputeMMS, and click Create Service Linked Role.
Configure data operation permissions for the source MaxCompute project.
This grants MMS access to source metadata and data reads during migration. You must use the source account to configure these permissions. We recommend granting the admin role directly.
MaxCompute console
Log in to the MaxCompute console and select a region in the upper-left corner.
In the left-side navigation pane, choose .
On the Projects page, click Manage in the Actions column for the target project.
Configure data operation permissions
Admin role
On the Project Settings page, click the Role Permissions tab.
Find the
adminrole and click Manage Members in the Actions column.In the Manage Members dialog box, enter
RAM$<account_id>:role/AliyunServiceRoleForMaxComputeMMSin the Add Member Manually text box. Replace<account_id>with your Alibaba Cloud account ID.Click OK.
Create a custom role
Create a project role in MaxCompute and grant it only the data operation permissions required by MMS.
On the Project Settings page, click the Role Permissions tab.
Click Create Project-level Role, configure the role as prompted, and click Confirm.
The following table describes the parameters.
Parameter
Required
Description
Role Name
Required
The name must be 1 to 64 characters in length, and can contain letters and digits. The name must start with a letter.
Role Type
Required
Admin: A management role.
You can grant management permissions by using a policy, but you cannot grant resource permissions.
You cannot grant management permissions by using an ACL.
Resource: A resource-type role.
You can grant resource permissions by using a policy or an ACL, but you cannot grant management permissions.
Authorization Method
Required
Access Control List (ACL): A whitelist-based authorization mechanism that allows users or roles to perform specific actions on specific objects.
Policy: A mechanism that supports both allow and deny rules, suitable for large enterprises and complex scenarios that require fine-grained control.
Grants a user permissions to perform operations on projects, tables, models, resources, functions, or instances. The following table lists the permissions that you can grant.
Object
Permissions
Table
Describe, Select, Update, Alter, Drop, ShowHistory, Download
Resource
Read, Write, Download, Delete
Function
Read, Write, Download, Execute, Delete
Package
Read
Project
Read, Write, List, CreateTable, CreateInstance
Return to the Role Permissions tab, select the new project-level role, and click Manage Members in the Actions column. Select the Alibaba Cloud account or RAM user to authorize and click OK. If you cannot find the account when you authorize it for the first time, you can add it in the Add Member Manually section.
Via SQL
Connect to MaxCompute by using the odpscmd client and add the service-linked role that you created.
USE <target_projectname>; -- Add the service-linked role to the user. Add USER `RAM$<account_id>:role/AliyunServiceRoleForMaxComputeMMS`;Grant permissions to the user.
MaxCompute supports permission control at various levels. During project operations, you can grant permissions based on the scope of operations.
Coarse-grained authorization: Directly grant the admin role to the user. This way, you avoid having to grant permissions for each table individually.
GRANT admin TO USER `RAM$<account_id>:role/AliyunServiceRoleForMaxComputeMMS`;Fine-grained authorization: Grant permissions at the project, table, or instance level.
Project-level permissions
-- Grant project-level data operation permissions. GRANT <actions> ON project <project_name> TO USER `RAM$<account_id>:role/AliyunServiceRoleForMaxComputeMMS`; -- Supported actions Read,Write,List,CreateTable,CreateInstance,CreateFunction,CreateResource,All -- Example 1 GRANT Read,Write,List,CreateTable,CreateInstance,CreateFunction,CreateResource ON project <project_name> TO USER `RAM$<account_id>:role/AliyunServiceRoleForMaxComputeMMS`; -- Example 2 GRANT ALL ON project <project_name> TO USER `RAM$<account_id>:role/AliyunServiceRoleForMaxComputeMMS`;Table-level permissions
-- Grant table-level data operation permissions. GRANT <actions> ON table <table_name> [(<column_list>)] TO USER `RAM$<account_id>:role/AliyunServiceRoleForMaxComputeMMS`; -- Supported actions Describe,Select,Alter,Update,Drop,ShowHistory,All -- Example 1 GRANT Describe,Select,Alter,Update,Drop,ShowHistory ON table <table_name> [(<column_list>)] TO USER `RAM$<account_id>:role/AliyunServiceRoleForMaxComputeMMS`; -- Example 2 GRANT All ON table <table_name> [(<column_list>)] TO USER `RAM$<account_id>:role/AliyunServiceRoleForMaxComputeMMS`;Instance-level permissions
-- Grant instance-level data operation permissions. GRANT <actions> ON instance <instance_id> [(<column_list>)] TO USER `RAM$<account_id>:role/AliyunServiceRoleForMaxComputeMMS`; -- Supported actions Read,Write,All -- Example 1 GRANT Read,Write ON instance <instance_id> [(<column_list>)] TO USER `RAM$<account_id>:role/AliyunServiceRoleForMaxComputeMMS`; -- Example 2 GRANT All ON instance <instance_id> [(<column_list>)] TO USER `RAM$<account_id>:role/AliyunServiceRoleForMaxComputeMMS`;
Parameter description:
target_projectname: Required. The name of the target project.
account_id: Required. The ID of your Alibaba Cloud account.
privileges: Required. The name of the operation permission to be granted. You can specify multiple operations at a time. Separate them with commas (,).
The following table lists the permissions required for the source MaxCompute project.
Object
Permission
Table
Describe
Project
List, CreateInstance
Grant the source service-linked role (
AliyunServiceRoleForMaxComputeMMS) permission to readinformation_schema.Log in to the MaxCompute console and select a region in the upper-left corner.
In the left-side navigation pane, choose .
On the Tenants page, click the Roles tab.
On the Roles tab, click Add Role. In the Add Role dialog box, enter a custom Role Name, provide the Policy Content, and then click OK.
The Policy Content is as follows:
{ "Statement":[ { "Action":[ "odps:Describe", "odps:Select" ], "Effect":"Allow", "Resource":[ "acs:odps:*:catalogs/system_catalog/schemas/information_schema/tables/*" ] }, { "Action":[ "odps:List" ], "Effect":"Allow", "Resource":[ "acs:odps:*:catalogs/system_catalog/schemas/information_schema" ] } ], "Version":"1" }On the Tenants page, click the Users tab.
On the Users tab, click Add Member. In the Add Member dialog box, select or add the desired accounts. In the Batch Set Roles section, select the roles, click
, and then click OK.
Data migration permissions
SQL mode migration
The source project must grant the destination's service-linked role (
AliyunServiceRoleForMaxComputeMMS) theSelectandDescribepermissions to read data from the source project.Scope
same-region migration.
cross-region migration. Supported regions include China (Shanghai), China (Hangzhou), China (Beijing), China (Shenzhen), and China (Ulanqab).
Authorization methods
Method 1: Cross-root account authorization. Connect to MaxCompute by using the odpscmd client.
Destination RAM user
To grant a RAM user in the destination account access to the source project, the destination RAM user must have the
adminandsuper_administratorpermissions on the destination project.Perform the following operations as the source root account or an authorized RAM user:
USE source_project; ADD USER `ALIYUN$destination_project_ram_user`; GRANT super_administrator TO USER `ALIYUN$destination_project_ram_user`;Perform the following operations as the destination RAM user:
You can grant the
adminrole or a custom role that has theselectanddescribepermissions on the tables to be migrated.USE source_project; ADD USER `RAM$destination_project_root_account:role/AliyunServiceRoleForMaxComputeMMS`; GRANT admin TO USER `RAM$destination_project_root_account:role/AliyunServiceRoleForMaxComputeMMS`;
Destination root account
Perform the following operations as the source root account or an authorized RAM user:
USE source_project; ADD USER `ALIYUN$destination_project_root_account`; GRANT super_administrator TO USER `ALIYUN$destination_project_root_account`;Perform the following operations as the destination root account:
You can grant the admin role or a custom role that has the
selectanddescribepermissions on the tables to be migrated.USE source_project; ADD USER `RAM$destination_project_root_account:role/AliyunServiceRoleForMaxComputeMMS`; GRANT admin TO USER `RAM$destination_project_root_account:role/AliyunServiceRoleForMaxComputeMMS`;
Method 2: Cross-project resource access based on packages. Use packages to grant the destination's service-linked role (
AliyunServiceRoleForMaxComputeMMS) access to the tables that you want to migrate in the source project.
Migration in Spark + Open Storage mode
Grant the
Describe,Select, andDownloadpermissions on tables to the source project's service-linked role (AliyunServiceRoleForMaxComputeMMS). This mode applies to cross-region data migration between regions that are not supported by the SQL mode.For details, see "Configure MaxCompute data operation permissions for users" in Step 4 of Preparations. We recommend granting the admin role directly. If you already granted the admin role during metadata synchronization setup, skip this step.
Configure the Storage API (optional)
Subscription Storage API
Use the subscription-based Storage API.
Purchase a Data Transmission Service quota in the source project's region.
Go to the MaxCompute console Purchase Page to purchase a new quota.
Set Product Type to Subscription and Specification Type to Data Transmission Service.
Run the following command to enable the Storage API for the source project:
setproject odps.tunnel.enable.quota.route.v2=true;Create a role and grant the source root account permission to use the quota.
Log in to the MaxCompute console and select a region in the upper-left corner.
In the left-side navigation pane, choose .
On the Tenants page, click the Roles tab.
On the Roles tab, click Add Role. In the Add Role dialog box, enter a custom Role Name, provide the Policy Content, and then click OK.
The Policy Content is as follows:
{ "Statement": [{ "Action": [ "odps:List", "odps:Usage"], "Effect": "Allow", "Resource": ["acs:odps:*:regions/*/quotas/*"]}], "Version": "1" }On the Tenants page, click the Users tab.
On the Users tab, click Add Member. In the Add Member dialog box, select or add the desired accounts. In the Batch Set Roles section, select the roles, click
, and then click OK.
Pay-as-you-go Storage API
Use the pay-as-you-go Storage API.
Enable the Storage API for the source project.
Log in to the MaxCompute console and select a region in the upper-left corner.
In the left-side navigation pane, choose .
On the Tenants page, click the Tenant Property tab.
On the Tenant Property tab, enable the Storage API Switch switch.
Create a role and grant the source root account permission to use the quota.
Log in to the MaxCompute console and select a region in the upper-left corner.
In the left-side navigation pane, choose .
On the Tenants page, click the Roles tab.
On the Roles tab, click Add Role. In the Add Role dialog box, enter a custom Role Name, provide the Policy Content, and then click OK.
The Policy Content is as follows:
{ "Statement": [{ "Action": [ "odps:List", "odps:Usage"], "Effect": "Allow", "Resource": ["acs:odps:*:regions/*/quotas/pay-as-you-go"]}], "Version": "1" }On the Tenants page, click the Users tab.
On the Users tab, click Add Member. In the Add Member dialog box, select or add the desired accounts. In the Batch Set Roles section, select the roles, click
, and then click OK.
Use a VPC peering connection or CEN to connect VPCs, and then add the IP address of the current region to the route. For more information, see the network configuration steps below.
STS role for cross-account OSS access (optional)
This role enables creating an external table at the source and reading data from the destination. Perform the following operations with the source MaxCompute account:
Create a RAM role
Log in to the RAM console.
In the left navigation bar, select .
On the Roles page, click Create Role.
For example, if the role name is
oss-cross-test, its ARN isacs:ram::<source_userID>:role/oss-cross-test. You must specify this ARN when you configure the data source.
Modify the trust policy of the RAM role
Log in to the RAM console.
In the left navigation bar, select .
On the Roles page, click the target Role Name to go to the role details page.
On the Trust Policy tab, click Edit Trust Policy, and on the Edit Trust Policy page, select the JSON Editor tab.
Configure the following policy:
{ "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": [ "<destination_root_account_id>@odps.aliyuncs.com", "odps.aliyuncs.com" ] } } ], "Version": "1" }
Create a permission policy
Log in to the RAM console.
In the left navigation bar, select .
On the Policies page, click Create Policy.
On the Create Policy page, select JSON Editor. Enter the following policy:
{ "Version": "1", "Statement": [ { "Action": [ "oss:ListBuckets", "oss:GetObject", "oss:ListObjects", "oss:PutObject", "oss:DeleteObject", "oss:AbortMultipartUpload", "oss:ListParts" ], "Resource": "*", "Effect": "Allow" } ] }
Attach the policy to the RAM role
Log in to the RAM console.
In the left navigation bar, select .
On the Roles page, click the target Role Name to go to the role details page.
On the Manage Permissions tab, click Create Authorization. In the Create Authorization panel that appears, select the policies to grant to the role, and click OK.
Network configuration
SQL mode migration
For same-region migration, only a NetworkLink is required.
For cross-region migration, the NetworkLink's VPC must have internet access. For more information, see Network access process.
Migration in Spark + Open Storage mode
The source and destination VPCs must be connected. For details, see VPC peering connection or Use CEN to connect VPCs.
Migration using Spark with OSS-based transit
OSS can be accessed over the internet or a VPC network.
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. It can contain only letters, digits, and Chinese characters.
Data Source Type
Yes
Select MaxCompute.
Network Connection
Yes
Select the network connection to use.
You can create a network connection in the MaxCompute console by choosing . MMS uses this connection to communicate with the VPC and connect to the data source.
MaxCompute source region
Yes
The region where the data source is located. The OSS endpoint for this region is used by default.
In cross-region scenarios:
If you specify either OSS Bucket or OSS Role ARN, the migration prioritizes the OSS-based transit mode.
If you do not specify either parameter, the migration defaults to the Spark and Open Storage mode.
OSS bucket
No
The name of the OSS bucket used to temporarily store external table data at the source. The bucket must be in the same region and under the same account as the source project. We recommend that you use this bucket only for migration staging. MMS deletes the files in the bucket after the migration is complete.
OSS role ARN
No
acs:ram::<source_userID>:role/<oss_sts_role_name>. This role is created during the source preparation.Root account ID
Yes
The UID of the Alibaba Cloud account that owns the source project.
MaxCompute source project
Yes
The name of the project to be migrated.
Project for MaxCompute source verification SQL
No
The project that provides the computing quota to run validation SQL on the source.
Default destination project
Yes
The destination project for the data migration. This setting cannot be changed after the data source is created.
Destination project list
No
If you need to migrate data from one data source to multiple destination projects, specify the destination projects in this list.
MaxCompute Execution Project
Yes
The project where migration jobs, such as Spark and SQL jobs, are run. These jobs use the default computing quota associated with this project.
Other Information
Configure the following optional parameters as needed.
Parameter
Description
Data Transfer Service Quota Name
The name of the exclusive Data Transfer Service resource group at the source.
If you use the Storage API at the source, you must specify the Data transfer service quota name:
For subscription, enter a custom level-1 quota name.
The Quota Name for the pay-as-you-go method is pay-as-you-go.
Using a VPC endpoint to access a MaxCompute source
Specifies whether to use a VPC for data migration.
Enabled: The migration uses a VPC network. Ensure that you have an active VPC network connection. For more information, see Network enablement process.
For same-region migration, you can directly select a VPC.
A Spark+Open Storage mode migration requires a VPC.
For a Spark+OSS mode migration, Spark accesses the source OSS through a VPC endpoint.
Disabled: Uses the public network.
If you use the Storage API at the source, you must enable this option.
Metastore Scheduled Update
Specifies whether MMS periodically pulls metadata from the data source.
Enabled: Metadata is pulled on a schedule. You can set the Update Cycle to daily or hourly and configure the Update Started At.
Daily: The update runs once a day at a specified time, accurate to the minute.
Hourly: The update runs once an hour at a specified minute.
Disabled: Metadata is not pulled on a schedule.
Metadata Access Concurrency
The number of concurrent requests to access the MaxCompute metastore. A higher value can speed up metadata retrieval.
Schema Whitelist
The schemas to migrate. Separate multiple schemas with commas (,).
Schema Blacklist
The schemas to exclude from the migration. Separate multiple schemas with commas (,).
Table blacklist
The MaxCompute tables to exclude from the migration.
The format for a single table is
schema.tableortable. Separate multiple tables with commas (,).Table Whitelist
The MaxCompute tables to migrate.
The format for a single table is
schema.tableortable. Separate multiple tables with commas (,).Maximum data migration task concurrency
The maximum number of concurrent data migration tasks. The default value is 20.
MaxCompute migration task SQL parameters
SQL parameters. For more information, see List of Flag parameters.
Maximum Number of Partitions per Task
The maximum number of partitions that a single MaxCompute Migration Assist (MMA) task can migrate. The default value is 50. Migrating partitions in batches reduces the number of SQL submissions and saves time. In most cases, you do not need to change this value.
Maximum data size per task (GB)
The default value is 5 GB. In most cases, you do not need to change this value.
Step 3: Synchronize metadata
After the data source starts, a job instance connects to MMS to synchronize metadata from the source. This metadata is required for configuring migration jobs.
This job instance consumes 4 CUs of computing resources. The system automatically shuts down the data source when no migration or metadata synchronization jobs are pending or running. Restart the data source to use it again.
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 the metadata for the data source changes and Scheduled Metastore update is enabled, the system automatically performs an update at the configured time. You do not need to manually synchronize the metadata.
After you configure the data source, create a migration job.