Synchronize data to iGraph with DataWorks
Data Integration, a service within DataWorks, provides high-speed, stable data synchronization between various data sources in complex network environments. It allows you to write data in batches from multiple sources to iGraph.
This topic describes how to perform a one-time full synchronization of data from MaxCompute to iGraph and how to configure a periodic task for incremental synchronization.
Prerequisites
1. You have purchased DataWorks on Alibaba Cloud.
2. You have purchased a suitable exclusive resource group for Data Integration. This resource group provides the necessary compute and network resources for data synchronization. For more information, see Use an exclusive resource group for Data Integration.
3. You have established network connectivity between the exclusive resource group for Data Integration and iGraph. For more information, see Network connectivity solutions. Before you configure a data synchronization task, ensure that your upstream and downstream data sources are connected to the exclusive resource group for Data Integration. A common practice is to place the data sources in the same VPC and bind the resource group to that VPC as described in the linked document.
4. You have prepared the data source environment. Before running the synchronization task, grant the data source account the required permissions to perform database operations. For more information, see Overview of database environment preparation.
5. You have a basic understanding of the script mode for offline synchronization. For more information, see Configure a task in script mode.
Procedure
1. Select a synchronization solution
The following table describes the available solutions for offline synchronization.
|
Synchronization solution |
Description |
|
One-time Full Synchronization |
Migrates all existing data from the source to iGraph in a single task. |
|
Periodic Incremental Synchronization |
Periodically synchronizes only the incremental data to iGraph. |
A common approach is to first perform a one-time full synchronization to migrate existing data to iGraph. Then, configure a periodic task to synchronize new data, ensuring eventual data consistency.
2. Create an offline synchronization node
Log on to the DataWorks console. In the left-side navigation pane, click Workspace List. Select the region where your workspace is located and click DataStudio in the corresponding workspace's row to open the DataStudio page.
Create a workflow. For more information, see Create a workflow. Then, to create an offline synchronization node, expand the workflow and right-click Data Integration > New Node > Offline Synchronization.
3. Configure the task in script mode
In the toolbar at the top of the node editing page, click the Convert to Script icon.
Paste your prepared script template. The following template shows how to synchronize data from MaxCompute to iGraph:
{
"type": "job",
"version": "2.0",
"steps": [
{
"stepType": "odps",
"parameter": {
"accessId": "${maxcompute_accessid}",
"accessKey": "${maxcompute_key}",
"odpsServer": "${maxcompute_server}",
"tunnelServer": "${maxcompute_tunnel}",
"isCompress": "false",
"partition": [
"ds=${maxcompute_partition}"
],
"column": [
"id",
"name"
],
"project": "${maxcompute_project}",
"table": "${maxcompute_table}"
},
"name": "Reader",
"category": "reader"
},
{
"stepType": "igraph",
"parameter": {
"graphName": "${igraph_graph}",
"endpoint": "${igraph_endpoint}",
"username": "${igraph_username}",
"password": "${igraph_password}",
"pkField": "id",
"column": [
"id",
"name"
],
"cmd": "ADD",
"labelName": "${igraph_label}"
},
"name": "Writer",
"category": "writer"
},
{
"copies": 1,
"parameter": {
"nodes": [],
"edges": [],
"groups": [],
"version": "2.0"
},
"name": "Processor",
"category": "processor"
}
],
"setting": {
"errorLimit": {
"record": "1"
},
"locale": "zh",
"speed": {
"throttle": false,
"concurrent": 4
}
},
"order": {
"hops": [
{
"from": "Reader",
"to": "Writer"
}
]
}
}
4. Run a one-time full offline synchronization
In the right-side Data Integration Resource Group Configuration panel, select your exclusive resource group for Data Integration and save the task.
In the top toolbar, click Run with Parameters. Enter the corresponding parameter values and click Run. To perform a full synchronization, set the maxcompute_partition parameter to *. This matches all partitions in the specified MaxCompute table. The partition configuration for MaxCompute supports Linux shell wildcards. For more information about the configuration rules, see MaxCompute Reader. For details on how to configure parameters for the iGraph data source, see iGraph Writer configuration.
If you need to use a different upstream data source, you can replace the Reader section in the script template. For a list of supported source data sources, see Supported data sources and read/write plug-ins.
After the run is complete, check the Log Panel at the bottom of the page to verify that the data synchronization task succeeded.
5. Configure scheduling for incremental synchronization
To run periodic incremental synchronization, you need to configure the task's scheduling properties. On the editing page of the offline synchronization node, click Scheduling Configuration in the right-side panel. The following sections explain how to configure node scheduling properties for your synchronization task. For instructions on using scheduling parameters, see Use scheduling parameters in Data Integration.
-
Configure Node Scheduling Properties: Assign values to the script variables, which serve as scheduling parameters. These values can be constants or other variables.
-
Configure Time Properties: Define the task's recurring schedule in the production environment, including how instances are generated, the scheduling type, and the scheduling period.
-
Configure Resource Properties: Select the scheduling resource group for the task to use during execution.
For example, to incrementally synchronize data from MaxCompute to iGraph, the upstream node must generate a new data partition containing the incremental data for each scheduling cycle. The partition name is usually linked to a time property. In this case, you can set the ${maxcompute_partition} parameter in the template to this time property and configure the task to depend on the upstream node that produces the partition.
Each time a new partition is generated, this offline synchronization task is automatically scheduled to synchronize the new data into iGraph.
6. Deploy the task
To run the task on a schedule, you must deploy it to the production environment. For more information, see Deploy tasks.