This topic describes how to migrate data from MaxCompute to Object Storage Service (OSS) by using the data synchronization feature of DataWorks.
Procedure
-
Activate services
Ensure that MaxCompute, DataWorks, and OSS are in the same region.
-
Create a table in DataWorks
-
Log in to the DataWorks console and select a region in the upper-left corner.
-
In the navigation pane on the left, choose Workspace.
-
On the Workspaces page, in the Actions column of the target workspace, choose .
-
On the DataStudio page, create a MaxCompute SQL node. Run the following statement to create a table named
transs.CREATE TABLE transs (name STRING, id STRING, gender STRING);
-
-
Import data into the
transstable-
Download the sample CSV file demo_data.csv to your computer.
-
In the navigation pane on the left, choose .
-
Click Go to Data Upload and Download.
-
In the left navigation bar, click the upload icon
, and click Data Upload.Upload the data file to the MaxCompute table named
transs.
-
-
Prepare the destination in OSS
-
Log in to the OSS console.
-
In the left-side navigation pane, click Buckets.
-
On the Buckets page, click Create Bucket.
-
Create an empty file named
qwee.csvon your computer and upload it to the bucket. This file will be populated with the data from MaxCompute. Ensure that the field names inqwee.csvare identical to the field names in thetransstable.For more information about how to upload a file, see Upload files.
-
-
Add a MaxCompute data source in DataWorks
-
Log in to the DataWorks console and select a region in the upper-left corner.
-
In the navigation pane on the left, choose Workspace.
-
On the Workspaces page, click the name of the target workspace.
-
On the Workspace Details page, click Data Sources in the navigation pane on the left.
-
On the Data Source tab, click Add Connection, and then select MaxCompute.
-
On the Add MaxCompute Data Source page, fill in the Basic Information.
For more information, see Configure a MaxCompute data source.
-
-
Add an OSS data source in DataWorks
For more information, see Configure an OSS data source.
-
Configure a MaxCompute (ODPS) Reader and an OSS Writer
-
Log in to the DataWorks console and select a region in the upper-left corner.
-
In the navigation pane on the left, choose .
-
Select Workspace, and click Go to Data Studio.
-
On the left side of DataStudio, click
, and select .-
For the data source, select MaxCompute (ODPS).
-
For the data destination, select OSS.
-
-
On the node configuration page, configure the following parameters.
-
Data SourceAdd Method: Select the MaxCompute data source that you added.
-
Data SourceDestination: Select the OSS data source that you added.
-
SourceTable: Select the MaxCompute table that you created.
-
Destination-Text type: Select CSV.
-
Destination-File Name: The destination file name in OSS. You can include a path, such as
a.txtoraaa/bbb/cc.csv. -
Runtime Resource: Select the dedicated resource group that you created.
-
Leave the other parameters at their default values.
Alternatively, click the
icon above the configuration area to switch to script mode and configure the node using a script. The following code provides an example:{ "order":{ "hops":[ { "from":"Reader", "to":"Writer" } ] }, "setting":{ "errorLimit":{ "record":"0" }, "speed":{ "concurrent":1, "dmu":1, "throttle":false } }, "steps":[ { "category":"reader", "name":"Reader", "parameter":{ "column":[ "name", "id", "gender" ], "datasource":"odps_first", "partition":[], "table":"Transs" }, "stepType":"odps" }, { "category":"writer", "name":"Writer", "parameter":{ "datasource":"Trans", "dateFormat":"yyyy-MM-dd HH:mm:ss", "encoding":"UTF-8", "fieldDelimiter":",", "fileFormat":"csv", "nullFormat":"null", "object":"qwee.csv", "writeMode":"truncate" }, "stepType":"oss" } ], "type":"job", "version":"2.0" } -
-
Click Run.
-
-
Verify the data migration. After the task completes, go to the OSS console and check that the CSV file contains the data migrated from MaxCompute. For more information, see Download files.