Alibaba Cloud Elasticsearch enables you to search and analyze data stored in HBase. Use Data Integration in DataWorks to perform offline synchronization from HBase to an Alibaba Cloud Elasticsearch instance.
Background
DataWorks is an end-to-end big data development and governance platform built on big data engines. It integrates features such as data development, task scheduling, and data management. You can use synchronization tasks in DataWorks to quickly synchronize data from various data sources to Alibaba Cloud Elasticsearch.
-
Supported data sources include:
-
Alibaba Cloud databases (MySQL, PostgreSQL, SQL Server, MongoDB, and HBase)
-
Alibaba Cloud PolarDB-X (upgraded from DRDS)
-
Alibaba Cloud MaxCompute
-
Alibaba Cloud OSS
-
Alibaba Cloud Tablestore
-
Self-managed versions of HDFS, Oracle, FTP, DB2, and other supported database types
-
-
Scenarios:
-
Offline synchronization of big data to Alibaba Cloud Elasticsearch. You can synchronize an entire database or all data in a specific table. For more information, see Offline synchronization of an entire MySQL database to Elasticsearch.
-
Real-time synchronization of big data to Alibaba Cloud Elasticsearch. This method supports both full and incremental synchronization. For more information, see Real-time synchronization of an entire MySQL database to Elasticsearch.
-
Prerequisites
-
An HBase instance is created. For more information, see Create an instance.
-
An Alibaba Cloud Elasticsearch instance is created, and the Auto Indexing feature is enabled for the instance. For more information, see Create an Alibaba Cloud Elasticsearch instance and Configure YML parameters.
-
A DataWorks workspace is created. For more information, see Create a workspace.
-
You can synchronize data only to Alibaba Cloud Elasticsearch. Self-managed Elasticsearch is not supported.
-
The HBase instance, Alibaba Cloud Elasticsearch instance, and DataWorks workspace must be in the same region.
-
The HBase instance, Alibaba Cloud Elasticsearch instance, and DataWorks workspace must be in the same time zone. Otherwise, a time zone difference may occur between the source and destination data when you synchronize time-related data.
Billing
-
For information about the fees for an Alibaba Cloud Elasticsearch instance, see Elasticsearch billable items.
-
For information about the fees for a Data Integration resource group, see Resource group fees.
Procedure
Step 1: Prepare the source data
The following table creation statement and test data are used in this example. For more information about how to import data into an HBase instance, see Use HBase Shell to access.
-
Table creation statement
create 'student', {NAME => 'name'}, {NAME => 'ID'}, {NAME => 'gender'} -
Test data
Run the
putcommand to insert data into the table. Example:put 'student', 'row1', 'name:a', 'xiaoming'.Run the
scancommand to view the data in the table. Example:scan 'student'.
Step 2: Purchase and configure an exclusive resource group
Purchase an exclusive resource group for Data Integration and attach a VPC and a workspace to it. An exclusive resource group ensures fast and stable data transmission.
-
Log on to the DataWorks console.
-
In the top navigation bar, select a region. In the left-side navigation pane, click Resource Groups.
-
On the Exclusive Resource Group tab, click .
-
On the DataWorks Exclusive Resources (Subscription) page, set Resource Type to Exclusive Resource Group for Data Integration, enter a name for the resource group, and then click Buy Now to purchase the exclusive resource group.
For more information, see Step 1: Purchase a resource group.
-
In the Actions column of the exclusive resource group that you created, click Network Settings to attach a VPC.
NoteThis procedure synchronizes data over a VPC using an exclusive resource group for Data Integration. For more information, see Configure an IP address whitelist.
To synchronize data, the exclusive resource group must connect to the VPCs of both the HBase and Alibaba Cloud Elasticsearch instances. Attach the resource group to the Virtual Private Cloud (VPC), Zone, and VSwitch of both instances. To view the VPC information of the Alibaba Cloud Elasticsearch instance, see View the basic information of an Elasticsearch instance.
ImportantAfter attaching a VPC, you must add the vSwitch CIDR Block from the VPC to the private IP address whitelists for the HBase and Alibaba Cloud Elasticsearch instances. For more information, see Configure a public or private IP address whitelist for an Elasticsearch instance.
-
In the upper-left corner, click the back icon to return to the Resource List page.
-
In the Actions column for the exclusive resource group, click Attach Workspace to attach the destination workspace.
For more information, see Step 2: Associate a workspace.
Step 3: Add data sources
Add the HBase and Elasticsearch data sources to Data Integration in DataWorks.
-
Go to the Data Integration page.
-
Log on to the DataWorks console.
-
In the left-side navigation pane, click Workspace.
-
In the Actions column of the target workspace, choose .
-
-
In the left-side navigation pane, click Data Source.
-
Add an HBase data source.
-
On the Data Sources page, click Add Data Source.
-
In the Add Data Source dialog box, search for and select HBase.
-
In the Add HBase Data Source dialog box, configure the parameters in the Basic Information section.
For more information, see Configure an HBase data source.
-
In the Connection Configuration section, click Test Connectivity. A Connected status indicates a successful connection.
-
Click OK.
-
-
Add an Elasticsearch data source in the same way. For more information, see Configure an Elasticsearch data source.
Step 4: Configure and run an offline synchronization task
Configure and run an offline synchronization task on an exclusive resource group.
-
The following steps use the codeless UI. For information about how to use the code editor, see Configure a batch synchronization task by using the code editor and Elasticsearch Writer.
-
The following steps are performed on the legacy Data Development (DataStudio) page.
-
Go to the Data Development page.
-
Log on to the DataWorks console.
-
In the left-side navigation pane, click Workspace.
-
In the Actions column for the destination workspace, choose .
-
-
Create an offline synchronization node.
-
On the Data Development (
) tab, choose . -
Right-click the workflow that you created and choose .
-
In the Create Node dialog box, enter a name for the node and click OK.
-
-
Configure the network and resources.
-
In the Source section, select HBase from the Source drop-down list and select the name of the source data source from the Data Source Name drop-down list.
-
In the Resource Group section, select the exclusive resource group.
-
In the Destination section, select Elasticsearch from the Destination drop-down list and select the name of the destination data source from the Data Source Name drop-down list.
-
-
Click Next.
-
Configure the task.
-
In the Source section, select the table that you want to synchronize.
-
In the Destination section, configure the parameters.
-
In the Field Mapping section, map the Source Column to the Target Column. For more information, see Configure an offline synchronization task by using the codeless UI.
-
In the Channel Control section, configure the channel parameters.
For more information, see Configure an offline synchronization task by using the codeless UI.
-
-
Run the task.
-
(Optional) On the right side of the page, click Properties to configure the scheduling parameters. For more information, see Scheduling configuration.
-
In the top toolbar, click the Save icon to save the task.
-
In the top toolbar, click the Submit icon to submit the task.
If you configure scheduling properties, the task runs periodically. You can also click the Run icon in the upper-right corner of the node editor to run the task immediately.
A
Shell run successfully!message in the run log indicates that the task ran successfully.
-
Step 5: Verify synchronized data
Log on to the Kibana console of your Elasticsearch cluster and go to the Kibana homepage.
In the left navigation menu, click Dev tools.
-
On the Console tab, run the following command to view the synchronized data.
POST /student_info/_search?pretty { "query": { "match_all": {}} }Notestudent_infois the destination index name configured in the offline synchronization task.