This topic describes how to migrate data from MaxCompute to Tablestore.

Prerequisites

Procedure

  1. Create a table in the DataWorks console.
    1. Login DataWorks console.
    2. In the left-side navigation pane, click Workspaces.
    3. In the top navigation bar, select the region where the target workspace resides. Find the target workspace and click Data Analytics in the Actions column.
    4. Right-click a created workflow, Select new > MaxCompute > table.
    5. In create a table page, select the engine type, and enter table name.
    6. On the table editing page, click DDL Statement.
    7. In the DDL Statement dialog box, enter the following statement and click Generate Table Schema:
      create table Transs
      (name    string,
      id    bigint,
      gender    string);
    8. Click Submit to Production Environment.
  2. Import data to table Transs.
    1. Click Import on the DataStudio page.
    2. In data import wizard dialog box that appears, enter at least three letters to search for the table to which data is to be imported, and then click next Step.
    3. In the dialog box that appears, set Select Data Import Method to Upload Local File and click Browse next to Select File. Select the local file that you want to import. Then, specify other parameters.
      Example:
      qwe,145,F
      asd,256,F
      xzc,345,M
      rgth,234,F
      ert,456,F
      dfg,12,M
      tyj,4,M
      bfg,245,M
      nrtjeryj,15,F
      rwh,2344,M
      trh,387,F
      srjeyj,67,M
      saerh,567,M
    4. Click Next.
    5. Select how destination table fields match the source fields.
    6. Click Import Data.
  3. Create a table in the Tablestore console.
    1. Log on to the Tablestore console and create an instance. For more information, see Create instances.
    2. Create a table named Trans. For more information, see Create tables.
  4. Add data sources in the DataWorks console.
    1. Login DataWorks console.
    2. In the left-side navigation pane, click Workspaces.
    3. On the Workspaces page that appears, find the target workspace and click Data Integration in the Actions column.
    4. In the left-side navigation pane, Select data source, enter data source management page.
    5. Add Tablestore as a data source. For more information, see Configure a Table Store connection.
  5. Configure MaxCompute as the reader and Tablestore as the writer.
    1. Go to the data analytics page. Right-click the specified workflow and choose new > data integration > offline synchronization.
    2. In create a node dialog box, enter node name, and click submit.
    3. In the top navigation bar, choose Conversion scripticon.
    4. In script mode, click **icon.
    5. In import Template dialog box SOURCE type, data source, target type and data source, and click confirm.
    6. Modify JSON code and click the Run icon icon.
      Sample code:
      {
          "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": "INT"
                          }
                      ]
                  },
                  "name": "Writer",
                  "category": "writer"
              }
          ],
          "version": "2.0",
          "order": {
              "hops": [
                  {
                      "from": "Reader",
                      "to": "Writer"
                  }
              ]
          },
          "setting": {
              "errorLimit": {
                  "record": "0"
              },
              "speed": {
                  "throttle": false,
                  "concurrent": 1,
                  "dmu": 1
              }
          }
      }
  6. View the data of the newly created table in the Tablestore console.
    1. Log on to the Tablestore console.
    2. In the left-side navigation pane, click All Instances.
    3. On the page that appears, find the target instance and click the instance name to go to the Instance Management page. In the Tables section, click the name of the table whose data you want to view.
    4. On the page that appears, click the Data Editor tab to view the data.