You can use Data Transmission Service (DTS) to migrate data from Simple Log Service (SLS) to an ApsaraDB for ClickHouse cluster.
This feature is in preview. To enable this feature, submit a ticket.
Prerequisites
-
You have collected the data to be migrated into an SLS Logstore. For more information, see Data collection.
-
You have created a destination ApsaraDB for ClickHouse cluster. For more information, see Create a cluster.
-
You have created a database and a table in the destination ApsaraDB for ClickHouse cluster to receive the data. For more information, see Create a database, Create a table, and Object naming limits.
Note-
A Logstore in SLS corresponds to a database in the ApsaraDB for ClickHouse cluster, and a topic corresponds to a table.
-
In the ApsaraDB for ClickHouse cluster, do not create columns for index fields in the Logstore that start with
__and end with__.
-
Usage notes
|
Type |
Description |
|
Source database limits |
|
|
Other limits |
|
Billing
|
Migration type |
Task configuration fee |
Internet traffic fee |
|
Full data migration |
Free. |
Free in this example. |
|
Incremental data migration |
Charged. For details, see the billing overview. |
Database account permissions
|
Database |
Permissions |
References |
|
Destination ApsaraDB for ClickHouse cluster |
|
Prerequisites
Before you create a DTS instance, create a RAM user and grant it the required permissions. DTS uses the RAM user's AccessKey pair to read data from SLS.
-
Create a RAM user.
-
Go to the Users page on the RAM console.
-
In the upper-left corner of the page, click Create User.
-
Enter a Logon Name. For Access Mode, select to generate a permanent AccessKey.
-
Click OK.
ImportantAfter the RAM user is created, save the AccessKey ID and AccessKey Secret.
-
-
Return to the Users page and find the RAM user that you created.
-
For the target RAM user, click Add Permissions in the Actions column.
-
In the search box under permission policy, search for and select the AliyunLogReadOnlyAccess policy.
NoteThe AliyunLogReadOnlyAccess permission policy grants read-only permissions on SLS. A RAM user with this policy can access SLS. You can also create a custom policy to meet your specific needs. For more information, see Create a custom policy.
-
Click Grant Permissions.
Procedure
-
Navigate to the migration task list page for the destination region using one of the following methods.
From the DTS console
-
Log on to the Data Transmission Service (DTS) console.
-
In the navigation pane on the left, click Data Migration.
-
In the upper-left corner of the page, select the region where the migration instance is located.
From the DMS console
NoteThe actual operations may vary based on the mode and layout of the DMS console. For more information, see Simple mode console and Customize the layout and style of the DMS console.
-
Log on to the Data Management (DMS) console.
-
In the top menu bar, choose .
-
To the right of Data Migration Tasks, select the region where the migration instance is located.
-
-
Click Create Task to navigate to the task configuration page.
-
Optional: In the upper-right corner of the page, click New Configuration Page.
Note-
If you are already on the new configuration page (the button in the upper-right corner is Back to Previous Version), you can skip this step.
-
The parameters on the new and old configuration pages are different. We recommend that you use the new configuration page.
-
-
Configure the source and destination databases.
Category
Parameter
Description
N/A
Task Name
DTS automatically generates a task name. We recommend that you specify a descriptive name for easy identification. The name does not need to be unique.
Source Database
Select Existing Connection
-
To use a database instance that has been added to the system (created or saved), select the desired database instance from the drop-down list. The database information below will be automatically configured.
NoteIn the DMS console, this parameter is named Select a DMS database instance..
-
If you have not registered the database instance with the system, or do not need to use a registered instance, manually configure the database information below.
Database Type
Select SLS.
Access Method
Select Alibaba Cloud Instance.
Instance Region
Select the region of the source SLS Project.
Project
Select the source SLS Project.
Logstore
Select the source SLS Logstore.
AccessKey ID
Enter the AccessKey ID and AccessKey Secret of the RAM user that you created in the prerequisites.
AccessKey Secret
Destination Database
Select Existing Connection
-
To use a database instance that has been added to the system (created or saved), select the desired database instance from the drop-down list. The database information below will be automatically configured.
NoteIn the DMS console, this parameter is named Select a DMS database instance..
-
If you have not registered the database instance with the system, or do not need to use a registered instance, manually configure the database information below.
Database Type
Select ClickHouse.
Access Method
Select Alibaba Cloud Instance.
Instance Region
Select the region of the destination ApsaraDB for ClickHouse cluster.
Replicate Data Across Alibaba Cloud Accounts
In this example, a database instance under the current Alibaba Cloud account is used. Select No.
Cluster Type
Select the type of the ApsaraDB for ClickHouse cluster based on your business requirements.
Cluster ID
Select the ID of the destination ApsaraDB for ClickHouse cluster.
Database Account
Enter the database account for the destination ApsaraDB for ClickHouse cluster. For information about the required permissions, see Permissions required for database accounts.
Database Password
Enter the password for the database account.
-
-
After you complete the configuration, click Test Connectivity and Proceed at the bottom of the page.
NoteEnsure that the DTS service IP address segments are automatically or manually added to the security settings of the source and destination databases to allow access from DTS servers. For more information, see Add DTS server IP addresses to a whitelist.
-
Configure the task objects.
-
On the Configure Objects page, configure the objects that you want to migrate.
Parameter
Description
Migration Types
Only Full Data Migration + Incremental Data Migration is supported.
Processing Mode of Conflicting Tables
-
Precheck and Report Errors: Checks whether tables with the same names exist in the destination database. If no tables with the same names exist, the precheck is passed. If tables with the same names exist, an error is reported during the precheck, and the data migration task does not start.
NoteIf a table in the destination database has the same name but cannot be easily deleted or renamed, you can change the name of the table in the destination database. For more information, see Object name mapping.
-
Ignore Errors and Proceed: Skips the check for tables with the same names.
WarningSelecting Ignore Errors and Proceed may cause data inconsistency and business risks. For example:
-
If the table schemas are consistent and a record in the destination database has the same primary key value as a record in the source database:
-
During full migration, DTS keeps the record in the destination database. The record from the source database is not migrated.
-
During incremental migration, DTS does not keep the record in the destination database. The record from the source database overwrites the record in the destination database.
-
-
If the table schemas are inconsistent, only some columns of data may be migrated, or the migration may fail. Proceed with caution.
-
Capitalization of Object Names in Destination Instance
You can configure the case sensitivity policy for the names of migrated objects, such as databases, tables, and columns, in the destination instance. By default, DTS default policy is selected. You can also choose to keep the case sensitivity consistent with the default policy of the source or destination database. For more information, see Case sensitivity of object names in the destination database.
Selected Objects
-
Specify the database to receive data.
-
In the Selected Objects section, hover over the source Logstore and click the Edit icon that appears.
-
In the Edit Schema dialog box, change the Schema Name to the name of the database that will receive the data in the destination ApsaraDB for ClickHouse cluster.
NoteBy default, DTS maps the Logstore name to the database name of the destination ClickHouse cluster. If the Logstore name contains the
-character, the character is replaced with_. -
Click OK.
-
-
Specify the table to receive data.
-
Click Add Table next to Table.
-
In the Add Table dialog box, configure the migration objects and the destination table.
You can specify the granularity of migration objects as a Logstore or a topic:
-
Logstore granularity: In the Table Name text box, enter .*.
Important.* indicates all topics in the Logstore. Data from all topics in a Logstore can only be written to a single table.
-
Topic granularity: In the Table Name text box, enter the name of the source topic in the Logstore.
-
-
In the Destination Table Name text box, enter the name of the table that will receive data in the destination ApsaraDB for ClickHouse cluster.
Note-
If the migration object is a topic, click Add Table and map each topic to a table in the ApsaraDB for ClickHouse cluster.
-
If the migration object is a Logstore, do not click Add Table.
-
-
Click OK.
-
-
Specify the columns to receive data.
NoteIf the migration objects are topics, you must repeat the following steps to map each topic to a table in the ApsaraDB for ClickHouse cluster.
-
In the Selected Objects section, hover over the newly created table and click the Edit icon that appears.
-
In the Edit Table dialog box, determine the index fields (columns) to migrate.
NoteTo exclude a field from migration, click the
icon in the Actions column for that field. -
In the Destination Column Name text box, edit the name to match the corresponding column in the destination table.
-
Optional: In the Target Column Type column, select the data type for the corresponding column.
NoteFor information about the default data type mappings in DTS, see Migrate data from SLS to an ApsaraDB for ClickHouse cluster.
-
Optional: Configure non-indexed fields to migrate.
NoteYou can repeat the following steps to configure the non-indexed fields you need to migrate.
-
Click the
icon to add a new row and configure it. -
In the Column Name column, enter the name of the non-indexed field to migrate.
-
In the Destination Column Name column, enter the name of the column that will receive the data in the ApsaraDB for ClickHouse cluster.
-
Optional: In the Target Column Type column, select the data type for the corresponding column.
NoteFor information about the default data type mappings in DTS, see Migrate data from SLS to an ApsaraDB for ClickHouse cluster.
-
-
After configuring each field to be migrated, click Confirm.
-
-
-
Click Next: Advanced Settings to configure advanced parameters.
Parameter
Description
Dedicated Cluster for Task Scheduling
By default, DTS schedules tasks on a shared cluster. You do not need to select one. If you want more stable tasks, you can purchase a dedicated cluster to run DTS migration tasks.
Retry Time for Failed Connections
After the migration task starts, if the connection to the source or destination database fails, DTS reports an error and immediately begins to retry the connection. The default retry duration is 720 minutes. You can customize the retry time to a value from 10 to 1440 minutes. We recommend that you set the duration to more than 30 minutes. If DTS reconnects to the source and destination databases within the specified duration, the migration task automatically resumes. Otherwise, the task fails.
Note-
For multiple DTS instances that share the same source or destination, the network retry time is determined by the setting of the last created task.
-
Because you are charged for the task during the connection retry period, we recommend that you customize the retry time based on your business needs, or release the DTS instance as soon as possible after the source and destination database instances are released.
Retry Time for Other Issues
After the migration task starts, if a non-connectivity issue, such as a DDL or DML execution exception, occurs in the source or destination database, DTS reports an error and immediately begins to retry the operation. The default retry duration is 10 minutes. You can customize the retry time to a value from 1 to 1440 minutes. We recommend that you set the duration to more than 10 minutes. If the related operations succeed within the specified retry duration, the migration task automatically resumes. Otherwise, the task fails.
ImportantThe value of Retry Time for Other Issues must be less than the value of Retry Time for Failed Connections.
Start Incremental Synchronization from Selected Offset
You can choose whether to start migrating data from a specific checkpoint based on your business requirements. In this example, the default setting No is used.
NoteIf you select Yes, you must also select the checkpoint from the drop-down list.
Enable Throttling for Incremental Data Migration
If required, you can also choose to set speed limits for the incremental migration task. You can set RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s) to reduce the load on the destination database.
Note-
This configuration item is available only if you select Incremental Data Migration for Migration Types.
-
You can also adjust the incremental migration speed after the migration instance is running.
Environment Tag
Optional. Select an environment tag to identify the instance.
Configure ETL
Choose whether to enable the extract, transform, and load (ETL) feature. For more information, see What is ETL? Valid values:
-
Yes: Enables the ETL feature. Enter data processing statements in the code editor. For more information, see Configure ETL in a data migration or data synchronization task.
-
No: Disables the ETL feature.
Monitoring and Alerting
Select whether to set alerts and receive alert notifications based on your business needs.
-
No: Does not set an alert.
-
Yes: Configure alerts by setting an alert threshold and an alert notifications. If a migration fails or the latency exceeds the threshold, the system sends an alert notification.
-
-
-
Save the task and run a precheck.
-
To view the parameters for configuring this instance when you call the API operation, move the pointer over the Next: Save Task Settings and Precheck button and click Preview OpenAPI parameters in the bubble that appears.
-
If you do not need to view or have finished viewing the API parameters, click Next: Save Task Settings and Precheck at the bottom of the page.
Note-
Before the migration task starts, DTS performs a precheck. The task starts only after it passes the precheck.
-
If the precheck fails, click View Details next to the failed check item, fix the issue based on the prompt, and then run the precheck again.
-
If a warning is reported during the precheck:
-
For check items that cannot be ignored, click View Details next to the failed item, fix the issue based on the prompt, and then run the precheck again.
-
For check items that can be ignored, you can click Confirm Alert Details, Ignore, OK, and Precheck Again to skip the alert item and run the precheck again. If you choose to ignore a warning, it may cause issues such as data inconsistency and pose risks to your business.
-
-
-
Purchase the instance.
-
When the Success Rate is 100%, click Next: Purchase Instance.
-
On the Purchase page, select the link specification for the data migration instance. For more information, see the following table.
Category
Parameter
Description
New Instance Class
Resource Group Settings
Select the resource group to which the instance belongs. The default value is default resource group. For more information, see What is Resource Management?
Instance Class
DTS provides migration specifications with different performance levels. The link specification affects the migration speed. You can select a specification based on your business scenario. For more information, see Data migration link specifications.
-
After the configuration is complete, read and select Data Transmission Service (Pay-as-you-go) Service Terms.
-
Click Buy and Start. In the OK dialog box that appears, click OK.
You can view the progress of the migration task on the Data Migration Tasks list page.
Note-
If the migration task does not include incremental migration, it stops automatically after the full migration is complete. After the task stops, its Status changes to Completed.
-
If the migration task includes incremental migration, it does not stop automatically. The incremental migration task continues to run. While the incremental migration task is running, the Status of the task is Running.
-
-
Appendix
Data type mapping
|
SLS |
ClickHouse cluster |
|
TEXT |
STRING |
|
JSON |
STRING |
|
DOUBLE |
FLOAT64 |
|
LONG |
INT64 |
Table and field information
Table information
When you manually create a destination table, ensure that it meets the following requirements.
The ENGINE of the destination table must be ENGINE = ReplicatedReplacingMergeTree(_version, _is_deleted) to prevent data inconsistency.
-
For a ClickHouse Community Edition instance, you must create a local table and a distributed table. The name of the distributed table must match the table name specified for the synchronization objects. The local table must be named
<distributed_table_name>+_local. -
For a ClickHouse Enterprise Edition instance, you must create a table with the same name specified for the synchronization objects.
Field information
In addition to the source fields, the destination table must contain the following fields. Run the SELECT * FROM table_name final WHERE _sign>0; statement to query data. The WHERE clause filters out deleted data, and the final keyword deduplicates rows based on the sorting key.
|
Version |
Parameter |
Type |
Default |
Description |
|
ClickHouse Community Edition earlier than 23.8 |
_sign |
Int8 |
1 |
The DML operation type.
|
|
_version |
UInt64 |
1 |
The timestamp when the data is written to the ClickHouse cluster. |
|
|
ClickHouse Enterprise Edition and ClickHouse Community Edition 23.8 and later |
_sign |
Int8 |
1 |
The DML operation type.
|
|
_is_deleted |
UInt8 |
0 |
Indicates whether the record is deleted.
|
|
|
_version |
UInt64 |
1 |
The timestamp when the data is written to the ClickHouse cluster. |