This topic describes how to use the data synchronization feature of DataWorks to migrate data from an Alibaba Cloud Elasticsearch cluster to MaxCompute.
Prerequisites
-
MaxCompute is activated.
For instructions, see Activate MaxCompute.
-
DataWorks is activated.
For instructions, see Activate DataWorks.
-
A MaxCompute data source is added. For more information, see Associate a MaxCompute compute resource.
-
A workflow is created in DataWorks.
This tutorial uses a workflow in basic mode. For more information, see Create a workflow.
-
An Alibaba Cloud Elasticsearch cluster is created.
Verify that your Alibaba Cloud Elasticsearch cluster is running properly. To create a cluster, see Quick start: Create a cluster and retrieve data.
This tutorial uses an Alibaba Cloud Elasticsearch cluster with the following configuration:
-
Region: China (Shanghai)
-
Zone: Zone B
-
Version: 5.5.3 with Commercial Feature
-
Background
Elasticsearch is a distributed, multi-tenant, full-text search engine based on Lucene. Released as open-source software under the Apache License, it is a leading enterprise search engine.
Alibaba Cloud Elasticsearch offers various versions, such as 5.5.3, 6.3.2, and 6.7.0, all bundled with commercial features and the X-Pack plug-in. It is designed for data analysis and search scenarios, and adds enterprise-grade features such as granular access control, security monitoring and alerts, and automated reporting to the open-source Elasticsearch.
Procedure
-
Create a source table in Elasticsearch. For more information, see Use DataWorks to synchronize MaxCompute data to Alibaba Cloud Elasticsearch.
-
Create a destination table in MaxCompute.
-
Log on to the DataWorks console. In the target region, click in the left-side navigation pane. Select a workspace from the drop-down list and click Go to Data Development.
-
Right-click the workflow that you created and choose .
-
In the Create Table dialog box, enter a Name and click Create.
NoteIf multiple MaxCompute compute resources are associated with DataStudio, select the required MaxCompute Engine Instance.
-
At the top of the table editor page, click DDL.
-
In the DDL dialog box, enter the following statement and click Generate Table Schema.
create table elastic2mc_bankdata ( age string, job string, marital string, education string, default string, housing string, loan string, contact string, month string, day_of_week string ); Click Submit to Production Environment.
-
-
Synchronize the data.
Go to the data analytics page. Right-click the specified workflow and choose .
-
In the New node dialog box, enter a Name and click OK.
In the top navigation bar, choose
icon.In script mode, click
icon.In import Template dialog box SOURCE type, data source, target type and data source, and click confirm.
-
Configure the script.
For descriptions of the script parameters, see Elasticsearch Reader.
{ "type": "job", "steps": [ { "stepType": "elasticsearch", "parameter": { "retryCount": 3, "column": [ "age", "job", "marital", "education", "default", "housing", "loan", "contact", "month", "day_of_week", "duration", "campaign", "pdays", "previous", "poutcome", "emp_var_rate", "cons_price_idx", "cons_conf_idx", "euribor3m", "nr_employed", "y" ], "scroll": "1m", "index": "es_index", "pageSize": 1, "sort": { "age": "asc" }, "type": "elasticsearch", "connTimeOut": 1000, "retrySleepTime": 1000, "endpoint": "http://es-cn-xxxx.xxxx.xxxx.xxxx.com:9200", "password": "xxxx", "search": { "match_all": {} }, "readTimeOut": 5000, "username": "xxxx" }, "name": "Reader", "category": "reader" }, { "stepType": "odps", "parameter": { "partition": "", "truncate": true, "compress": false, "datasource": "odps_source",// The name of the MaxCompute data source. "column": [ "age", "job", "marital", "education", "default", "housing", "loan", "contact", "month", "day_of_week", "duration", "campaign", "pdays", "previous", "poutcome", "emp_var_rate", "cons_price_idx", "cons_conf_idx", "euribor3m", "nr_employed", "y" ], "emptyAsNull": false, "table": "elastic2mc_bankdata" }, "name": "Writer", "category": "writer" } ], "version": "2.0", "order": { "hops": [ { "from": "Reader", "to": "Writer" } ] }, "setting": { "errorLimit": { "record": "0" }, "speed": { "throttle": false, "concurrent": 1, "dmu": 1 } } }NoteYou can view the public endpoint and port number of your Alibaba Cloud Elasticsearch cluster on the Basic Information page.
-
Click the
Run icon to execute the code. -
You can view the results in the Run log.
-
Verify the result.
Right-click the workflow and choose .
In create a node dialog box, enter node name, and click submit.
-
In the ODPS SQL node editor, enter the following statement.
SELECT * FROM elastic2mc_bankdata; Click
icon to run the code.You can operation Log view the results.