All Products
Search
Document Center

ApsaraDB for ClickHouse:Migrate self-managed ClickHouse to ApsaraDB for ClickHouse Enterprise Edition

Last Updated:May 28, 2026

This topic describes how to migrate a self-managed ClickHouse cluster to ApsaraDB for ClickHouse Enterprise Edition using the console or manually.

Prerequisites

  • self-managed cluster: You have created a database account and password. The account must have read permissions on databases and tables and SYSTEM command execution privileges. If you need to migrate external tables that include account credentials, the account must also have the displaySecretsInShowAndSelect privilege.

  • target cluster: You have created a database account and password and ensured that the account has the highest privileges.

  • Network connectivity

    • If the self-managed cluster and the target cluster are in the same VPC, add the IP addresses of all nodes in the target cluster and the IPv4 CIDR blocks of the nodes' switches to the whitelist of the self-managed cluster.

      • To learn how to configure a whitelist for an ApsaraDB for ClickHouse cluster, see Configure a whitelist.

      • To configure the whitelist for the self-managed cluster, see its product documentation.

      • Run the SELECT * FROM system.clusters WHERE internal_replication = 1; command to query the IP addresses of all nodes in the ApsaraDB for ClickHouse cluster.

    • If the self-managed cluster and the target cluster are in different VPCs, or if the self-managed cluster is in an on-premises IDC or hosted by another cloud provider, first resolve any network connectivity issues. For more information, see Establish network connectivity between the target cluster and the data source.

      Note

      In this scenario, you can use IP mapping to prevent CIDR block conflicts between different VPCs. If you use IP mapping, you must also add the mapped IP addresses to the whitelists of both clusters.

Migration validation

Before you start data migration, we highly recommend creating a test environment to validate compatibility, performance, and migration feasibility. Perform the data migration in your production environment only after this validation is complete. This step is crucial, as it helps you identify and resolve potential issues early, ensuring a smooth migration and protecting your production environment.

  1. Create a migration task to perform the data migration.

  2. Analyze performance bottlenecks and verify migration feasibility.

  3. To validate cloud compatibility, use one of the following methods:

    1. Manual validation: See Compatibility Analysis and Resolution.

    2. Console validation: See (Optional) Check SQL compatibility.

Migration methods

Migration method

Pros

Cons

Use cases

console migration

Provides a visual workflow that automates metadata migration.

Limited to full and incremental migration of an entire cluster; does not support migrating specific databases and tables or a subset of historical data.

Migrating an entire cluster.

manual migration

Provides granular control over which databases and tables to migrate.

Involves a complex procedure and requires manual metadata migration.

  • Migrating specific databases and tables.

  • Migrating clusters where cold storage on a single node exceeds 1 TB.

  • Migrating clusters where hot data on a single node exceeds 10 TB.

  • Migrating an entire cluster that does not meet console migration requirements.

Procedure

Console migration

Considerations

During migration

  • The merge process is paused on the destination cluster for databases and tables being migrated, but continues on the self-managed cluster.

    Note

    If a migration task runs for too long, an excessive amount of metadata can accumulate on the destination cluster. The recommended duration for a migration task is no more than 5 days. The system automatically cancels tasks that exceed this limit.

  • The destination cluster must use the default cluster. If your self-managed cluster uses a different name, the system automatically converts the cluster definition in any distributed table to default.

Supported content

Note

The migration process converts the database and table structures for some engines. For details about engine conversions, see the tables below.

  • Database structure: The following table lists the supported database engine types.

    Engine name

    Conversion description

    Atomic

    Replaced with the Replicated engine

    Replicated

    No change

    Ordinary

    Replaced with the Replicated engine

  • Table structure: The following table lists the supported table engine types.

    Engine name

    Conversion description

    MaterializedView

    No change

    View

    GenerateRandom

    Buffer

    URL

    Null

    Merge

    SharedMergeTree

    SharedVersionedCollapsingMergeTree

    SharedSummingMergeTree

    SharedReplacingMergeTree

    SharedAggregatingMergeTree

    SharedCollapsingMergeTree

    SharedGraphiteMergeTree

    MergeTree

    Replaced with SharedMergeTree

    ReplicatedMergeTree

    VersionedCollapsingMergeTree

    Replaced with SharedVersionedCollapsingMergeTree

    ReplicatedVersionedCollapsingMergeTree

    SummingMergeTree

    Replaced with SharedSummingMergeTree

    ReplicatedSummingMergeTree

    ReplacingMergeTree

    Replaced with SharedReplacingMergeTree

    ReplicatedReplacingMergeTree

    AggregatingMergeTree

    Replaced with SharedAggregatingMergeTree

    ReplicatedAggregatingMergeTree

    ReplicatedCollapsingMergeTree

    Replaced with SharedCollapsingMergeTree

    CollapsingMergeTree

    GraphiteMergeTree

    Replaced with SharedGraphiteMergeTree

    ReplicatedGraphiteMergeTree

  • Data: Incremental migration is supported for data in tables of the MergeTree family.

Important
  • The system can automatically migrate the database and table structures listed above. Any other structures must be handled manually based on the warnings and errors encountered during the migration.

  • If your data does not meet these conditions, you can perform a manual migration.

Cluster impact

  • Self-managed cluster

    • Reading data from the self-managed cluster increases its CPU and memory usage.

    • DDL operations are not allowed.

  • Destination cluster

    • Writing data to the destination cluster increases its CPU and memory usage.

    • DDL operations are not allowed on the databases and tables included in the migration. This restriction does not apply to databases and tables that are not part of the migration.

    • The merge process is paused for tables and databases being migrated. This does not affect other tables and databases.

    • After the migration is complete, the cluster performs frequent merge operations for a period. This increases I/O utilization and can lead to higher latency for business requests. To mitigate the potential impact, Calculate Merge Time After Migration and plan accordingly.

Step 1: Check cluster and enable system tables

Before you begin the data migration, configure the config.xml file on your self-managed cluster to enable incremental migration. The configuration depends on whether the system.part_log and system.query_log system tables are already enabled.

If system tables are not enabled

If you have not enabled system.part_log and system.query_log, add the following configurations to the config.xml file.

system.part_log
<part_log>
    <database>system</database>
    <table>part_log</table>
    <partition_by>event_date</partition_by>
    <order_by>event_time</order_by>
    <ttl>event_date + INTERVAL 15 DAY DELETE</ttl>
    <flush_interval_milliseconds>7500</flush_interval_milliseconds>
</part_log>
system.query_log
<query_log>
    <database>system</database>
    <table>query_log</table>
    <partition_by>event_date</partition_by>
    <order_by>event_time</order_by>
    <ttl>event_date + INTERVAL 15 DAY DELETE</ttl>
    <flush_interval_milliseconds>7500</flush_interval_milliseconds>
</query_log>

If system tables are enabled

  1. Ensure the configurations of system.part_log and system.query_log in the config.xml file match the following content. Inconsistencies may cause the data migration to fail or proceed slowly.

    system.part_log
    <part_log>
        <database>system</database>
        <table>part_log</table>
        <partition_by>event_date</partition_by>
        <order_by>event_time</order_by>
        <ttl>event_date + INTERVAL 15 DAY DELETE</ttl>
        <flush_interval_milliseconds>7500</flush_interval_milliseconds>
    </part_log>
    system.query_log
    <query_log>
        <database>system</database>
        <table>query_log</table>
        <partition_by>event_date</partition_by>
        <order_by>event_time</order_by>
        <ttl>event_date + INTERVAL 15 DAY DELETE</ttl>
        <flush_interval_milliseconds>7500</flush_interval_milliseconds>
    </query_log>
  2. After modifying the configuration, run the drop table system.part_log and drop table system.query_log statements. Inserting data into a business table automatically recreates the system.part_log and system.query_log tables.

Step 2: Configure cluster compatibility

To ensure the target cluster is as compatible as possible with the self-managed cluster, connect to the target cluster and modify the compatibility parameter to match the version of your self-managed cluster.

Important

Setting the compatibility to an earlier version disables some new features, such as ParallelReplica.

For example:

SELECT currentProfiles(); // Get the current profile name.
SELECT
    profile_name,
    setting_name,
    value
FROM system.settings_profile_elements
WHERE (setting_name = 'compatibility') AND (profile_name = 'xxxx'); // Check the value of the compatibility setting.
ALTER PROFILE XXXX SETTINGS compatibility = '23.8'; // Set the compatibility value.

Step 3: Create a migration task

  1. Log on to the ApsaraDB for ClickHouse console. On the Clusters page, select Enterprise Edition Clusters, and then click the ID of the target cluster.

  2. In the navigation pane, choose Data Migration and Synchronization > Migration from ClickHouse.

  3. Click Create Migration Task.

  4. Select the source and target instances.

    Parameter

    Description

    Example

    Task Name

    A unique, case-insensitive name for the migration task. The name can contain only letters and digits.

    MigrationTask1229

    Source Cluster Name

    Run SELECT * FROM system.clusters; to obtain the cluster name of your self-managed cluster.

    default

    VPC IP Address

    The IP addresses and ports for each shard in the cluster, separated by commas. Format: IP:PORT,IP:PORT,....

    You can use the following SQL statement to get the IP addresses and ports of your self-managed cluster:

    SELECT shard_num, replica_num, host_address as ip, port FROM system.clusters WHERE cluster = '<cluster_name>' and replica_num = 1;

    Parameter description:

    • cluster_name: The name of your self-managed cluster.

    • replica_num=1 selects the first replica set. You can also select another replica set or manually choose one replica from each shard.

    Important
    • You cannot use the VPC domain name or SLB address of the ClickHouse cluster.

    • If you use NAT to map IP addresses and ports to Alibaba Cloud, you must configure the mapped IP addresses and ports according to your network setup.

    192.168.0.5:9000,192.168.0.6:9000

    Database Account

    The database account for the self-managed cluster.

    test

    Database Password

    The password for the database account of the self-managed cluster.

    test******

    Source Instance Kernel Version

    Click Get Version.

    22.8.5.29

  5. Based on the source instance version, proceed as follows:

    • If the source instance version is 22.10 or later: Click Next.

    • If the source instance version is earlier than 22.10: Enter the Destination Instance Information as prompted, and then click Next.

    • If version retrieval fails: This can happen if the source instance information is incorrect or the network is disconnected. Follow the prompt to resolve the issue, and then click Get Version again.

    Note

    Due to parameter incompatibilities between earlier community editions and the Enterprise Edition, if the source instance version is earlier than 22.10, you must synchronize data by pushing it from the source to the target. In this scenario, you must map the target instance's IP address to the self-managed network. If the self-managed network and the Enterprise Edition instance are in the same VPC, or if they are connected through a VPC Peering Connection, you can use the original IP addresses for the connection.

  6. Check connectivity and configurations.

    1. Click Start Check.

      The check verifies the following items:

      • Connectivity verification: Verifies that the self-managed cluster and the target instance have full network connectivity and that all nodes can access each other.

      • Account permission verification: Verifies that the source account and password are correct and can connect to the source instance.

      • Source instance system table check: Verifies that the self-managed instance has the system.query_log, system.parts, and system.part_log system tables.

      • Configuration check: Verifies that the self-managed instance and target instance use the same time zone, and the compatibility parameter of the target instance matches the source instance version.

    2. During the check, you can click the image icon in the upper-right corner to view the real-time progress.

    3. After the check is complete, proceed based on the results.

      You can select a Result level and a check item, and then click the image icon to view the corresponding results. Result levels are described below.

      • Success: If all checks pass, click Next to continue.

      • Warning: These are non-blocking items. You must manually confirm if the warning affects your workload or the migration task. You can either ignore the warning or resolve the issue and click Start Check again.

      • Error: These are blocking items. You must resolve the error using the provided information and then click Start Check again.

        For information about error messages and solutions, see FAQ.

  7. Check Database and Table Structures.

    After the connectivity and configuration check passes, proceed to check the database and table structures. This step consists of three sub-steps: Select databases to migrate, Select tables to migrate, and Check database and table structures.

    Important

    The Select databases to migrate and Select tables to migrate sub-steps are optional. If you want to migrate all databases and tables from the source instance, you can skip these two sub-steps and proceed directly to sub-step 3 (Check database and table structures).

    Sub-step 1: Select databases to migrate (Optional)

    1. Click Query Source. The system automatically queries all databases on the source instance.

    2. During the query, you can click Query Results to view the real-time results.

    3. After the query is complete, select the databases to migrate based on your business requirements. After the selection is complete, click Confirm.

    Sub-step 2: Select tables to migrate (Optional)

    1. After you select the databases, the interface for selecting tables is displayed. Click Query Source. The system automatically queries all tables in the selected databases.

    2. During the query, you can click Query Results to view the real-time results.

    3. After the query is complete, select the tables to migrate based on your business requirements. After the selection is complete, click Confirm.

    Note

    By default, all tables are selected. If you only need to migrate specific tables, deselect the select-all checkbox for the corresponding database, expand the dropdown list, and select the tables you need.

    Sub-step 3: Check database and table structures

    1. Click Start Check. The system checks the database structures, table structures, and UDFs to identify any incompatibilities between the source and target instances.

    2. During the check, you can filter by Result Level and Check Item, and click the Refresh icon to view real-time results.

    3. Check results are classified into three levels: success, warning, and error.

      • Check succeeds: Click Next to proceed with the migration.

      • Warnings occur during the check

        Set the result level to Warning and find the corresponding check items to review the warning details.

        Important

        Warning-level check items are non-blocking. You must confirm whether the warning affects your workload or the migration task. After your confirmation, you have two options:

        • Ignore the warning and click Next to continue the migration.

        • Resolve the warning based on the provided details, and then click Start Check to recheck the database and table structures. For information about warning messages and solutions, see the FAQ section of this topic.

      • Check fails

        Set the result level to Error and find the corresponding check items to review the error details.

        Important

        Error-level check items are blocking. You must resolve the errors based on the provided details, and then click Start Check to recheck the database and table structures. For information about error messages and solutions, see the FAQ section of this topic.

  8. Migrate Database and Table Structures.

    1. Click Start Migration.

    2. During the migration, you can click the image icon in the upper-right corner to view the real-time progress.

    3. After the migration is complete, proceed based on the results.

      For information about the results, see Step 5.

  9. (Optional) Check SQL compatibility.

    The SQL compatibility check replays SQL statements from your self-managed instance on the target instance to verify syntax compatibility between different kernel versions.

    • To skip this step, click skip.

    • To perform this check, select a Request replay time and click Start Check. If the check passes, click Next. If the check fails, see Step 5 for solutions.

      Important
      • The instance databases and tables contain no data, so this check only validates syntax compatibility. To test with data, you can migrate some data in the next step.

      • Mismatches between the client version used for SQL replay and the target instance can cause false positives. If errors occur, run the SQL statements manually to verify the results.

  10. Record and clean up Kafka/RabbitMQ engine tables.

    Before starting synchronization, record the definitions of Kafka/RabbitMQ engine tables and their downstream materialized views on the self-managed cluster, handle implicit tables, and then drop these tables to avoid migration exceptions.

    1. Log on to the self-managed cluster and query all Kafka and RabbitMQ engine tables along with their downstream dependencies.

      /*
      create_table_query: table definition
      dependencies_database: database of the downstream dependent table
      dependencies_table: name of the downstream dependent table
      From dependencies_database and dependencies_table, you can identify the materialized views that depend on the Kafka/RabbitMQ tables.
      */
      SELECT * FROM system.tables WHERE engine IN ('RabbitMQ', 'Kafka');
    2. View the materialized view definitions and check whether their target tables are implicit tables.

      /*
      View the materialized view definition.
      If the target table of a materialized view is an implicit table, note the following:
      Dropping the materialized view also drops the implicit table, which causes data loss.
      Example: In CREATE MATERIALIZED VIEW [db.]table_name [TO[db.]name], if TO is not specified,
      the system automatically creates an implicit table, which may be in the format '.inner_id.<TABLE_UUID>' or '.inner.<TABLE>'.
      */
      SELECT * FROM system.tables WHERE database='<DATABASE>' AND name = '<MATERIALIZED_VIEW_NAME>';
    3. If a materialized view's target table is an implicit table, rename it to a new name to prevent data loss when the materialized view is dropped later.

      -- Rename the implicit target table to preserve data
      RENAME TABLE <DATABASE>.`.inner_id.<TABLE_UUID>` TO <DATABASE>.<new_target_table_name>;
    4. Drop the Kafka/RabbitMQ engine tables and their downstream materialized views.

      -- Drop the materialized views first
      DROP TABLE <DATABASE>.<MATERIALIZED_VIEW_NAME>;
      -- Then drop the Kafka/RabbitMQ engine tables
      DROP TABLE <DATABASE>.<KAFKA_OR_RABBITMQ_TABLE_NAME>;
    Important

    Make sure to save all recorded DDL statements. You will need them to recreate these tables on both the self-managed cluster and the target cluster later. If you performed the RENAME operation, use the TO clause to point to the renamed target table when recreating the materialized views.

  11. Start Synchronization.

    1. Click Start Sync.

    2. During synchronization, you can click the image icon in the upper-right corner to view the real-time progress.

      During synchronization, use the Stop, Restart, and Cancel Migration operations to control the migration process. Click to view details about these operations.

      Actions

      Description

      Impact

      Use case

      Stop

      Immediately stops data migration and proceeds to migrate the remaining database and table structures.

      • Data may not be fully migrated.

      • Before you restart the migration, you must clear the migrated data from the target cluster to avoid data duplication.

      • Manually stopping the migration task after all data has been migrated.

      • Testing with a partial data migration without having to stop writes on the self-managed cluster.

      Restart

      If an error occurs during a check or migration step, this operation retries the failed step after you resolve the issue.

      None

      Resume the task from the point of failure after resolving a migration error.

      Cancel Migration

      Forcibly cancels the task and skips all subsequent steps.

      Important

      After cancellation, the migration task is locked, preventing you from modifying the migration process. You can use the Previous, Next, or Refresh buttons to view the results of completed steps.

      • The migration task is forcibly terminated. The database and table structures and configurations of the target instance may be incomplete and cannot be used for production workloads.

      • Before you restart the migration, you must clear the migrated data from the target cluster to avoid data duplication.

      The migration task is negatively affecting the self-managed cluster, and you need to end it quickly to resume writes.

    3. On the self-managed cluster, use the previously saved DDL statements to recreate the Kafka/RabbitMQ engine tables and their downstream materialized views. After recreation, incremental data resumes flowing in and is automatically synchronized to the target cluster.

      Important

      If you performed the RENAME operation on the implicit target table earlier, use the TO clause to point to the renamed target table when recreating the materialized views. For more information, see CREATE MATERIALIZED VIEW.

      CREATE MATERIALIZED VIEW [db.]table_name [TO[db.]name]

      .

      -- Recreate the Kafka/RabbitMQ engine table on the self-managed cluster
      CREATE TABLE <DATABASE>.<KAFKA_OR_RABBITMQ_TABLE_NAME> (...)
      ENGINE = Kafka/RabbitMQ
      SETTINGS ...;
      
      -- Recreate the materialized view (pointing to the renamed target table)
      CREATE MATERIALIZED VIEW <DATABASE>.<MATERIALIZED_VIEW_NAME> TO <DATABASE>.<new_target_table_name>
      AS SELECT ... FROM <DATABASE>.<KAFKA_OR_RABBITMQ_TABLE_NAME>;
    4. When the process reaches the Migrate data stage, switch to the Migrate data tab and click the image icon to view the Migration Progress and Estimated remaining time.

      Assess whether the migration can be completed

      The migration's success depends on the migration speed relative to the write speed of the self-managed cluster.

      • The following table provides migration speed test data:

        Average part size

        Source instance type

        Source disk type

        Target instance type

        Target storage medium

        Cluster nodes

        Single-node speed

        Overall migration speed

        402.54MB

        8C32G

        PL1

        16CCU

        OSS

        16

        47MB/s

        752.34MB/s

        402.54MB

        80C384G

        PL3

        48CCU

        ESSD_L2

        8

        197.74MB/s

        1581.95MB/s

      • Compare the write speeds of the target cluster and the self-managed cluster:

        Data migration speed depends on factors such as part size (in our tests, we observed fast migration speeds for an average part size between 100 MB and 10 GB), instance type, disk type, and workload characteristics. Therefore, the test data is for reference only. To determine the actual write speed of the target cluster, check its disk throughput. For more information about how to view disk throughput, see View cluster monitoring information.

        • If the write speed of the target cluster is slower than that of the self-managed cluster: The migration is likely to fail. We recommend canceling the task and performing a manual migration.

        • If the write speed of the target cluster is faster than that of the self-managed cluster: To improve the success rate, we recommend ensuring that the migration time, calculated as Data Volume / (Migration Speed - Self-managed Cluster Write Speed), is no more than 5 days.

      Important
      • You must closely monitor the Migration Progress. Based on the Estimated remaining time, you need to proactively stop writes to the self-managed cluster and handle tables that use the Kafka and RabbitMQ engines.

      • The background process automatically cancels any task that runs longer than 5 days. If your migration task requires more time, submit a ticket to request a threshold adjustment.

      Estimate when to stop writes to the self-managed cluster and perform cutover

      When the estimated migration time is less than 10 minutes or the migration progress reaches 99%, perform the following operations to complete the cutover:

      1. Stop business writes. On the self-managed cluster, drop the previously recreated Kafka/RabbitMQ engine tables and their downstream materialized views.

        -- Drop the materialized views first
        DROP TABLE <DATABASE>.<MATERIALIZED_VIEW_NAME>;
        -- Then drop the Kafka/RabbitMQ engine tables
        DROP TABLE <DATABASE>.<KAFKA_OR_RABBITMQ_TABLE_NAME>;
      2. Wait for the migration progress to reach 100% and the migration to fully complete.

      3. Connect to the target cluster and use the previously saved DDL statements to recreate the Kafka/RabbitMQ engine tables and their downstream materialized views.

        Important

        If you performed the RENAME operation on the implicit target table earlier, use the TO clause to point to the renamed target table when recreating the materialized views. For more information, see CREATE MATERIALIZED VIEW.

        -- Recreate the Kafka/RabbitMQ engine table on the target cluster
        CREATE TABLE <DATABASE>.<KAFKA_OR_RABBITMQ_TABLE_NAME> (...)
        ENGINE = Kafka/RabbitMQ
        SETTINGS ...;
        
        -- Recreate the materialized view (pointing to the renamed target table)
        CREATE MATERIALIZED VIEW <DATABASE>.<MATERIALIZED_VIEW_NAME> TO <DATABASE>.<new_target_table_name>
        AS SELECT ... FROM <DATABASE>.<KAFKA_OR_RABBITMQ_TABLE_NAME>;
      4. Verify that the data pipeline on the target cluster is working properly and that data is flowing in as expected.

    5. When the Migration Progress reaches 100% and you confirm that writes to the source instance have stopped, click Stop to end the data migration and proceed to the next steps.

      image

    6. After the synchronization is complete, click Completed.

      Important

      After the Start Synchronization step is complete, the migration task is locked, and you cannot modify the migration process. You can still use the Previous, Next, or Refresh buttons to view the results of completed steps.

Step 4: Migrate data for non-MergeTree tables

During a migration task, non-MergeTree tables either support only table structure migration (for example, MySQL tables) or do not support migration at all (for example, Log tables). Therefore, after the migration task is complete, the target cluster may contain tables with a structure but no business data. You must manually migrate the business data as follows:

  1. Log on to the self-built cluster and identify the non-MergeTree tables requiring data migration.

    SELECT
        `database` AS database_name,
        `name` AS table_name,
        `engine`
    FROM `system`.`tables`
    WHERE (`engine` NOT LIKE '%MergeTree%') AND (`engine` != 'Distributed') AND (`engine` != 'MaterializedView') AND (`engine` NOT IN ('Kafka', 'RabbitMQ')) AND (`database` NOT IN ('system', 'INFORMATION_SCHEMA', 'information_schema')) AND (`database` NOT IN (
        SELECT `name`
        FROM `system`.`databases`
        WHERE `engine` IN ('MySQL', 'MaterializedMySQL', 'MaterializeMySQL', 'Lazy', 'PostgreSQL', 'MaterializedPostgreSQL', 'SQLite')
    ))
  2. Log on to the target cluster and use the remote function to migrate the data.

Manual migration

Migrate from self-managed ClickHouse to Enterprise Edition

image.png

Note

In ApsaraDB for ClickHouse Enterprise Edition, you only need to create the corresponding target table, regardless of whether your source table has shards or replicas. The system automatically uses the SharedMergeTree table engine, so you can omit complex engine parameters in the target table definition. The ApsaraDB for ClickHouse Enterprise Edition cluster automatically handles vertical and horizontal scaling, so you do not need to worry about the implementation details of replication and sharding.

Overview

The following procedure describes how to migrate from a self-managed ClickHouse cluster to an ApsaraDB for ClickHouse Enterprise Edition cluster.

  1. Add a read-only user to the source cluster.

  2. Replicate the source table structure on the target cluster.

  3. If the source cluster is accessible from an external network, pull data from the source cluster to the target cluster. Otherwise, push data from the source cluster to the target cluster.

  4. (Optional) Remove the IP address of the source cluster from the allow list of the target cluster.

  5. Remove the read-only user from the source cluster.

Procedure

  1. Perform the following operations on the source cluster. This procedure assumes that the source table already contains data.

    1. Add a read-only user for the db.table table.

      CREATE USER exporter
      IDENTIFIED WITH SHA256_PASSWORD BY 'password-here'
      SETTINGS readonly = 1;
      GRANT SELECT ON db.table TO exporter;
    2. Copy the source table structure.

      SELECT create_table_query
      FROM system.tables
      WHERE database = 'db' and table = 'table'
  2. Perform the following operations on the target cluster.

    1. Create a database.

      CREATE DATABASE db
    2. Use the source table's CREATE TABLE statement to create the target table.

      Note

      When you run the CREATE TABLE statement, change the ENGINE to SharedMergeTree and omit any parameters. The ApsaraDB for ClickHouse Enterprise Edition cluster always replicates the table and provides the correct parameters. The ORDER BY, PRIMARY KEY, PARTITION BY, SAMPLE BY, TTL, and SETTINGS clauses define the table's structure and metadata. Keep these clauses to ensure the table is created correctly on the target ApsaraDB for ClickHouse Enterprise Edition cluster.

      CREATE TABLE db.table ...
    3. Use the Remote function to pull or push data.

      Note

      If the source ClickHouse server is not accessible from an external network, push data from the source cluster rather than pulling it from the target cluster. The Remote function supports both SELECT (pull) and INSERT (push) operations.

      • On the target cluster, use the Remote function to pull data from the source table.

        image.png

        INSERT INTO db.table SELECT * FROM
        remote('source-hostname:9000', db, table, 'exporter', 'password-here')
      • On the source cluster, use the Remote function to push data to the target cluster.

        image.png

        Note

        Add the IP addresses of the source cluster to the allow list of the target cluster to enable the Remote function to connect to your ApsaraDB for ClickHouse Enterprise Edition cluster. For more information, see Configure an allow list.

        INSERT INTO FUNCTION
        remote('target-hostname:9000', 'db.table',
        'default', 'PASS') SELECT * FROM db.table

FAQ

Connectivity and configuration errors

Error message

Description

Solution

Tcp connectivity check failed for '{host}:{port}':{error}.

The network connection to the self-built cluster timed out.

Use the error message to troubleshoot the network issue.

No such cluster: {cluster}, please run 'SELECT DISTINCT(cluster) FROM system.clusters;' to check

The cluster specified in the migration task configuration was not found on the self-built cluster.

Query the self-built cluster for the correct cluster name using SQL, and then update the migration task configuration.

not exists

One or more of the following system tables are missing from the self-built cluster: system.query_log, system.parts, and system.part_log.

Create the missing system tables on the self-built cluster.

Timezone mismatch with source, which may cause time data anomalies.

The timezone of the self-built cluster does not match the target cluster's timezone.

Align the timezone settings of the clusters.

Compatibility mismatch with source version, which may cause incompatibility.

The compatibility setting of the target cluster is incompatible with the self-built cluster's version.

Adjust the target cluster's compatibility setting to match the self-built cluster's version.

Important

Setting compatibility to an earlier version disables features like ParallelReplica.

Database and table schema errors

Error message

Description

Solution

ERROR: Not consistent across nodes.

The database and table schemas are inconsistent across the nodes of the self-built cluster.

Check the schemas on each node of the self-built cluster and resolve any inconsistencies.

ERROR: Cannot get secrets (shown as [HIDDEN]), please set display_secrets_in_show_and_select=1 (restart required).

Passwords in the database and table schemas are hidden.

Set the display_secrets_in_show_and_select parameter to 1 and restart the cluster.

Note: This operation requires the displaySecretsInShowAndSelect account permission.

ERROR: Unsupported engine.

The migration process does not support the self-built cluster's database engine.

Change the database engine to one supported by the target instance.

WARN:Unsupported engine, it will be automatically replaced with a Replicated database to bypass migration exceptions.

The database engine of the self-built cluster is not supported for migration.

To bypass migration exceptions, the system automatically replaces the engine with a Replicated database.

WARN:Unsupported engine, please replace the data synchronization capability with DTS, or create a same-name database to bypass migration exceptions.

The database engine of the self-built cluster is not supported for migration.

Use Data Transmission Service (DTS) to synchronize data, or create a database with the same name on the target instance to bypass migration exceptions.

WARN:Unsupported engine, it will be automatically ignored during migration.

Migration is not supported for tables that use certain engines.

The migration process automatically ignores this engine.

WARN: Using the Distributed engine is not recommended because it can cause scaling issues in enterprise instances. Drop this table and query the underlying MergeTree table directly.

Using the distributed table engine is not recommended in ApsaraDB for ClickHouse Enterprise Edition.

Drop the distributed table on the self-built cluster. After migration, query the underlying MergeTree table directly.

WARN:Please confirm referenced IP addresses are accessible.

This warning flags potentially unreachable IP addresses but does not confirm an accessibility issue.

Ensure the target instance can reach the referenced IP addresses. If not, establish connectivity and add the IP addresses to the allowlist.

WARN:Only structure, does not support data migration.

For tables that use certain engines, only the schema is migrated; data migration is not supported.

Migrate the data manually, for example, using the remote function.

WARN:Unsupported engine, please create a same-name MergeTree table manually to bypass migration exceptions.

Migration is not supported for tables that use certain engines.

Create a MergeTree table with the same name on the target instance and migrate the data manually.

WARN:Ignored engine, please create table manually.

Migration is not supported for tables that use certain engines.

See Step 4 in the Procedure section.

ERROR: Table has data in destination cluster.

For the schema check to succeed, the corresponding table in the target instance must be empty.

Delete the data from the corresponding table in the target instance.

ERROR: Unsupported function origin.

Only user-defined Functions with function.origin="SQLUserDefined" are supported for migration.

Create the required function manually on the target instance.

Other

For solutions to other migration issues, see the FAQ.