This topic shows you how to migrate data from MaxCompute to Tablestore using the data integration and data development features of DataWorks.
Procedure
-
Activate services
-
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.
-
-
Create a table in the Tablestore console
-
Log on to the Tablestore console and create an instance.
-
Create a data table named trans. For more information, see Create a data table.
Set the primary key to name and id.
-
-
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 a Tablestore data source. For more information, see Configure a Tablestore data source.
-
Configure the MaxCompute (ODPS) Reader and Tablestore 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 Data source, select Tablestore.
-
Select MaxCompute as the data destination.
-
-
On the node configuration page, configure the following parameters.
-
Data Source-Source: Select the MaxCompute data source you added.
-
Data Source-Destination: Select the Tablestore data source you added.
-
Data Source-Table: Select the source table in MaxCompute.
-
Destination-Table: Select the destination table in Tablestore.
-
Runtime Resource: Select the exclusive resource group you created.
-
Keep the default values for other parameters.
Alternatively, click the
icon above the configuration area to switch to script mode.{ "type": "job", "steps": [ { "stepType": "odps", "parameter": { "partition": [], "datasource": "odps_first", "column": [ "name", "id", "gender" ], "table": "transs" }, "name": "Reader", "category": "reader" }, { "stepType": "ots", "parameter": { "datasource": "transs", "column": [ { "name": "gender", "type": "STRING" } ], "writeMode": "UpdateRow", "table": "trans", "primaryKey": [ { "name": "name", "type": "STRING" }, { "name": "id", "type": "STRING" } ] }, "name": "Writer", "category": "writer" } ], "version": "2.0", "order": { "hops": [ { "from": "Reader", "to": "Writer" } ] }, "setting": { "errorLimit": { "record": "0" }, "speed": { "throttle": false, "concurrent": 1, "dmu": 1 } } } -
-
-
Verify the migrated data in the Tablestore console.
-
登录表格存储控制台,在左上角选择地域。
-
在左侧导航栏选择All Instances。
-
在All Instances页面下,单击实例名称,进入Instance Management页面。
-
在Instance Management页面,单击Instance Details页签。
-
在Instance Details页签下方Tables区域,单击要查看的数据表名称。
-
在数据表管理页面,单击Query Data页签,查看新增的表数据。
-