Use Data Transmission Service (DTS) to synchronize data from a PolarDB-X 1.0 instance to an Elasticsearch cluster. DTS supports schema synchronization, full data synchronization, and incremental data synchronization — giving you a live, queryable replica in Elasticsearch for search and log analysis workloads.
How Elasticsearch maps to relational databases
Elasticsearch organizes data differently from relational databases. In Elasticsearch, an index is equivalent to a database in a relational system, and a document is equivalent to a row. Before you configure the synchronization task, review the concept mapping:
| Elasticsearch | Relational database |
|---|---|
| Index | Database |
| Type | Table |
| Document | Row |
| Field | Column |
| Mapping | Database schema |
Prerequisites
Before you begin, ensure that you have:
A source PolarDB-X 1.0 instance that uses RDS MySQL as its storage type (custom RDS for MySQL instances or standalone RDS for MySQL instances). PolarDB for MySQL is not supported.
A destination Elasticsearch instance. To create one, see Create an Alibaba Cloud Elasticsearch instance.
A destination Elasticsearch instance with more storage space than the source PolarDB-X 1.0 instance.
Billing
| Synchronization type | Pricing |
|---|---|
| Schema synchronization and full data synchronization | Free |
| Incremental data synchronization | Charged. See Billing overview. |
Supported SQL operations for incremental synchronization
| Operation type | SQL operations |
|---|---|
| DML | INSERT, UPDATE, DELETE |
UPDATE cannot remove fields from Elasticsearch documents.
Limitations
Source database requirements
Tables must have PRIMARY KEY or UNIQUE constraints. Tables with only UNIQUE constraints do not support schema synchronization — use PRIMARY KEY constraints where possible. Constraint fields must be unique; otherwise, duplicate data may appear in the destination.
If you select tables as synchronization objects and need to configure column mappings, a single task supports a maximum of 1,000 tables. If the table count exceeds this limit, the task submission returns an error. In that case, split the tables across multiple tasks, or synchronize the entire database as a single object.
The source PolarDB-X 1.0 instance must be version 5.2 or later.
Binary logging is enabled by default on RDS MySQL instances attached to PolarDB-X 1.0. Verify that
binlog_row_imageis set tofull— if it is not, the precheck will fail and the task will not start. To check the current value, run the following query on the RDS MySQL instance attached to PolarDB-X 1.0:SHOW GLOBAL VARIABLES WHERE Variable_name = 'binlog_row_image';Expected output when the parameter is correctly set:
+------------------+-------+ | Variable_name | Value | +------------------+-------+ | binlog_row_image | FULL | +------------------+-------+If the value is not
FULL, set it through the RDS console. See View instance parameters.Binary log retention requirements:
Incremental synchronization only: retain binary logs for at least 24 hours.
Full and incremental synchronization: retain binary logs for at least seven days. After full synchronization completes, you can reduce the retention period to more than 24 hours. If DTS cannot read the binary logs due to a short retention period, the task may fail or produce inconsistent data — issues caused by insufficient retention are not covered by the DTS Service-Level Agreement (SLA).
Operations to avoid during synchronization
Do not change the network type of the source PolarDB-X 1.0 instance during synchronization. If you do, update the network connection settings of the synchronization task immediately.
Do not scale out, scale in, synchronize hot spot tables, change shard keys, or make DDL changes on the source instance. These operations cause task failure or data inconsistency.
Do not write new data to the source instance during full-only synchronization. To keep data consistent in real time, run schema synchronization, full data synchronization, and incremental data synchronization together.
Do not run DDL operations that change database or table schemas during schema synchronization or full synchronization.
During full synchronization, DTS queries the source database, which creates metadata locks that may block DDL operations.
Other limitations
DTS does not synchronize INDEX, PARTITION, VIEW, PROCEDURE, FUNCTION, TRIGGER, or FOREIGN KEY objects.
To add columns to a source table: first update the corresponding field mapping in the Elasticsearch instance, then run the DDL statement in the source database, and finally pause and restart the synchronization task.
Synchronizing to Elasticsearch indexes that use parent-child relationships or Join field types is not supported and may cause task errors or query failures.
Incremental synchronization consistency depends on the continuity of XA transactions in PolarDB-X 1.0. If XA transaction continuity is disrupted — for example, when modifying synchronization objects or during disaster recovery for the incremental data collection module — uncommitted XA transactions may be lost.
Run synchronization during off-peak hours. Full synchronization consumes significant read and write resources on both the source and destination databases.
DTS attempts to recover failed tasks automatically for up to seven days. Before switching traffic to the destination instance, stop or release the synchronization task, or use the
revokecommand to revoke DTS write access on the destination — this prevents automatic recovery from overwriting destination data.Development and test Elasticsearch instance specifications are not supported.
If a task fails, DTS support staff will attempt to restore it within eight hours. During restoration, they may restart the task or adjust DTS task parameters (not database parameters). For parameters that may be changed, see Modify instance parameters.
DTS periodically updates thedts_health_check.ha_health_checktable in the source database to advance the binary log offset.
Database account permissions
| Database | Required permissions | How to create accounts and grant permissions |
|---|---|---|
| Source PolarDB-X 1.0 | Read permission on the synchronization objects | Account Management |
| Destination Elasticsearch | Read and write permissions. The default account is elastic. | — |
Data type mappings
DTS maps MySQL data types to Elasticsearch types during initial schema synchronization. For the full mapping table, see Data type mappings for initial schema synchronization.
DTS does not set themappingparameter fordynamicduring schema migration — the behavior depends on your Elasticsearch instance configuration. If your source data is in JSON format, all values for the same key must use the same data type across all rows in a table. For details, see dynamic.
Create a synchronization task
Step 1: Open the data synchronization page
Open the data synchronization task list in the destination region using one of these methods:
DTS console
Log on to the DTS console.DTS console
In the left navigation pane, click Data Synchronization.
In the upper-left corner, select the region where the synchronization instance will reside.
DMS console
The steps may differ based on the mode and layout of the DMS console. See Simple mode console and Customize the layout and style of the DMS console.
Log on to the DMS console.DMS console
In the top menu bar, choose Data + AI > DTS (DTS) > Data Synchronization.
To the right of Data Synchronization Tasks, select the region of the synchronization instance.
Step 2: Configure the source and destination databases
Click Create Task, then configure the following settings on the task configuration page.
Task name
DTS generates a task name automatically. Specify a descriptive name for easy identification. Names do not need to be unique.
Source database
| Parameter | Description |
|---|---|
| Select Existing Connection | Select a registered database instance from the drop-down list to auto-fill the settings below. If no registered instance is available, configure the fields manually. In the DMS console, this field is labeled Select a DMS database instance. |
| Database Type | Select PolarDB-X 1.0. |
| Access Method | Select Alibaba Cloud Instance. |
| Instance Region | Select the region of the source PolarDB-X 1.0 instance. |
| Replicate Data Across Alibaba Cloud Accounts | Select No. This example uses the same Alibaba Cloud account for source and destination. |
| Instance ID | Select the instance ID of the source PolarDB-X 1.0 instance. |
| Database Account | Enter the database account for the source PolarDB-X 1.0 instance. |
| Database Password | Enter the password for the database account. |
Destination database
| Parameter | Description |
|---|---|
| Select Existing Connection | Select a registered database instance from the drop-down list to auto-fill the settings below. If no registered instance is available, configure the fields manually. In the DMS console, this field is labeled Select a DMS database instance. |
| Database Type | Select Elasticsearch. |
| Access Method | Select Alibaba Cloud Instance. |
| Instance Region | Select the region of the destination Elasticsearch instance. |
| Type | Select Cluster Edition or Serverless as needed. |
| Instance ID | Select the instance ID of the destination Elasticsearch instance. |
| Database Account | Enter the account used to connect to the Elasticsearch instance. This is the username you set when creating the instance. The default account is elastic. |
| Database Password | Enter the password for the database account. |
| Encryption | Select HTTP or HTTPS as needed. |
After completing the configuration, click Test Connectivity and Proceed at the bottom of the page.
Add the CIDR blocks of the DTS servers to the security settings of both the source and destination databases. This can be done automatically or manually. See Add the IP address whitelist of DTS servers.
If the source or destination is a self-managed database (that is, Access Method is not Alibaba Cloud Instance), also click Test Connectivity in the CIDR Blocks of DTS Servers dialog box.
Step 3: Configure the synchronization objects
On the Configure Objects page, set the following parameters.
Synchronization Types
DTS always enables Incremental Data Synchronization. By default, also select Schema Synchronization and Full Data Synchronization. After the precheck, DTS initializes the destination cluster with a full copy of the selected source objects as the baseline for incremental synchronization.
Processing Mode of Conflicting Tables
Precheck and Report Errors: checks whether an index with the same name exists in the destination. If no conflict exists, the check passes. If a conflict is found, the precheck reports an error and the task does not start.
If you cannot delete or rename the conflicting index, set an object name mapping for the synchronization object to avoid naming conflicts.
Ignore Errors and Proceed: skips the conflict check for indexes that share a name with source objects.
WarningThis option may cause data inconsistency. If mapping structures match, records with the same primary key as the source are kept during initialization and overwritten during incremental synchronization. If mapping structures do not match, initialization may fail or only partial columns may synchronize.
Index Name
Table Name: creates a destination index with the same name as the source table.
Database Name_Table Name: creates a destination index named as
<database name>_<table name>.
The selected index name format applies to all tables.
Capitalization of object names in destination instance
Configures the case-sensitivity policy for database, table, and column names. The DTS default policy is selected by default. See Case policy for destination object names.
Source Objects and Selected Objects
In the Source Objects box, select the objects to synchronize, then click
to move them to the Selected Objects box.
Select objects at the table level. If you select an entire database, tables added or deleted in the source are not synchronized to the destination.
In the Selected Objects box:
To rename a single object in the destination, right-click it. See Map a single object name.
To rename multiple objects in bulk, click Batch Edit in the upper-right corner. See Map multiple object names in bulk.
To filter rows using a WHERE clause, right-click the table and set the filter condition. See Set filter conditions.
Only underscores (_) are allowed as special characters in index and type names. Object name mapping may cause synchronization failures for other objects that depend on the renamed object.Step 4: Configure advanced settings
Click Next: Advanced Settings and configure the following.
| Parameter | Description |
|---|---|
| Dedicated Cluster for Task Scheduling | DTS uses a shared cluster by default — no selection needed. For greater task stability, purchase a dedicated cluster. See What is a DTS dedicated cluster? |
| Retry Time for Failed Connections | How long DTS retries after a connection failure. Default: 720 minutes. Range: 10–1,440 minutes. 30 minutes or more is recommended. The task resumes automatically if the connection is restored within this period. |
| Retry Time for Other Issues | How long DTS retries after a non-connection error (such as a DDL or DML execution error). Default: 10 minutes. Range: 1–1,440 minutes. 10 minutes or more is recommended. Must be less than Retry Time for Failed Connections. |
| Enable Throttling for Full Data Synchronization | Limits the full synchronization rate to reduce load on the destination. Configure Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s). Available only when Synchronization Types includes Full Data Synchronization. |
| Enable Throttling for Incremental Data Synchronization | Limits the incremental synchronization rate. Configure RPS of Incremental Data Synchronization and Data synchronization speed for incremental synchronization (MB/s). |
| Environment Tag | A tag to identify the environment for this instance. |
| Shard Configuration | The number of primary shards and replica shards for the index. Base this on the maximum shard configuration of the destination Elasticsearch instance. |
| String Index | How strings are indexed in Elasticsearch. analyzed: analyze the string before indexing; select an analyzer. See Analyzers. not analyzed: index the raw value without analysis. no: do not index the string. |
| Time Zone | The time zone to use when synchronizing time-type data (such as DATETIME or TIMESTAMP). |
| DOCID | The document ID field. Defaults to the table's primary key. If the table has no primary key, DOCID is the auto-generated ID column in Elasticsearch. |
| Configure ETL | Whether to enable extract, transform, and load (ETL). Yesalert notifications: enter data processing statements in the code editor. See Configure ETL in a data migration or data synchronization task. No: disable ETL. |
| Monitoring and Alerting | Whether to configure alerts for task failures or latency exceeding a threshold. Yes: set alert thresholds and notification contacts. See Configure monitoring and alerting during task configuration. No: no alerts. |
If multiple DTS instances share a source or destination database, the shortest configured Retry Time for Failed Connections among all instances applies to all of them.
DTS charges for task runtime during connection retries. Set the retry duration based on your business needs, or release the DTS instance promptly after releasing the source or destination.
If time-type data in the destination should not include time zone information, set the document type for that field in the destination Elasticsearch instance before starting synchronization.You can also adjust the full synchronization throttle while the instance is running.
Step 5: Configure routing and document ID
Click Next: Configure Database and Table Fields to configure the _routing strategy and _id value for each table to be synchronized.
| Parameter | Description |
|---|---|
| Set _routing | _routing controls which shard a document is routed to. See _routing. Yes: define a custom column for routing. No: route using _id. For Elasticsearch 7.x destination instances, select No. |
| _routing Column | The column to use for routing. Required only when Set _routing is Yes. |
| Value of _id | The column to use as the document ID. |
Step 6: Save and run the precheck
To view the OpenAPI parameters for this task, hover over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters in the tooltip.
Click Next: Save Task Settings and Precheck to save the configuration and start the precheck.
DTS runs a precheck before starting any synchronization task. The task starts only if the precheck passes.
If the precheck fails, click View Details next to the failed item, resolve the issue as described, and rerun the precheck.
If the precheck returns warnings:
For non-ignorable warnings, click View Details, fix the issue, and run the precheck again.
For ignorable warnings, click Confirm Alert Details > Ignore > OK, then click Precheck Again to proceed. Ignoring warnings may lead to data inconsistency — proceed with caution.
Step 7: Purchase the instance
When the Success Rate reaches 100%, click Next: Purchase Instance.
On the Purchase page, select the billing method and link specifications.
Category Parameter Description New Instance Class Billing Method Subscription — pay upfront for a set duration. Cost-effective for long-term, continuous tasks. Monthly options: 1–9 months. Yearly options: 1, 2, 3, or 5 years. Pay-as-you-go — billed hourly for actual usage. Suitable for short-term or test tasks. Resource Group Settings — The resource group for the instance. Defaults to default resource group. See What is Resource Management? Instance Class — DTS offers synchronization specifications at different performance levels. Select a specification based on your requirements. See Data synchronization link specifications. Read and select Data Transmission Service (Pay-as-you-go) Service Terms.
Click Buy and Start, then click OK in the confirmation dialog box.
Monitor the task on the data synchronization page.
What's next
Monitor synchronization latency and task status from the DTS console.
Before switching production traffic to the destination Elasticsearch cluster, stop or release the synchronization task, or revoke DTS write access on the destination using the
revokecommand.