Skip to main content
The database Cross-cluster Data Migration Tool is provided by StarRocks Community. You can use this tool to easily migrate data from the source cluster to the target cluster.

Preparations

Migrate from Shared-nothing

On source cluster

You do not need to perform any preparations on the source cluster.

On target cluster

The following preparations must be performed on the target cluster for data migration.

Open ports

If you have enabled the firewall, you must open these ports: Migrate between Shared-data

On source cluster

During migration, the source cluster’s Auto-Vacuum mechanism may delete historical data versions that the target CNs still need to read. To prevent this situation, you must extend the Auto-Vacuum grace period by dynamically setting the FE configuration item lake_autovacuum_grace_period_minutes to a significantly large value:
Important This setting prevents the source cluster from reclaiming stale object storage files during migration, which will cause storage amplification. It is recommended to keep the migration window as short as possible, and to reset this item to its default value 30 after migration.

On target cluster

The following preparations must be performed on the target cluster for data migration.

Open ports

If you have enabled the firewall, you must open these ports:

Disable Compaction

You must disable Compaction on the target cluster during migration to prevent conflicts with incoming replication data.
  1. Dynamically disable Compaction:
  2. To prevent Compaction from being re-enabled after a cluster restart, also add the following configuration to the FE configuration file fe.conf:
Important After migration is complete, re-enable Compaction by removing the above configuration from fe.conf, and enable Compaction dynamically by executing:

Create source storage volumes on the target cluster

The Migration Tool identifies which storage volume each source table uses, and looks up a corresponding storage volume on the target cluster using the naming convention src_<source_volume_name>. You must pre-create these storage volumes before starting migration. Important These storage volumes are used only during migration to give target CNs read access to the source cluster’s object storage. After migration is complete, they are no longer needed and can be dropped.
  1. On the source cluster, list all storage volumes:
  2. For each storage volume used by the tables you plan to migrate, describe it to get its configuration:
    Example output:
  3. On the target cluster, create a mirrored storage volume using the same object storage credentials, but with the name prefixed by src_:
    Note
    • Set aws.s3.enable_partitioned_prefix to false regardless of the source cluster’s setting. The migration tool reads files using the source partition’s full path directly, so partitioned prefix must not be applied to the mirrored volume.
    • Repeat this step for each unique storage volume used by the tables to be migrated. For example, if the source uses builtin_storage_volume, create src_builtin_storage_volume on the target cluster.
    • It is recommended to use temporary credentials (access key / secret key) for the source storage volume. These can be revoked after migration is complete.

Migrate range-distributed tables

Range-distributed table migration is supported only between shared-data clusters. The migration tool creates a missing target table automatically from the source table definition. Do not create the target table manually. Record the original values of the following FE configurations. For each dynamic setting, also add the matching persistent setting to fe.conf on every applicable FE so that an FE restart does not change the migration contract.
  1. On both the source and target clusters, disable tablet merge and keep range distribution enabled:
  2. enable_execute_script_on_frontend is a static configuration. Set it to true in fe.conf on every source and target FE, and restart the FEs before the migration window.
  3. On the target cluster, disable automatic tablet split and merge by setting the target size to 0:
    Do not use a very large value instead. The tool creates target tables from the source table definitions, so a source table with the table property tablet_reshard_target_size keeps it on the target, and that table property would take the place of the large value for the table. 0 disables automatic split and merge for every table. The splits submitted by the tool use explicit boundaries and do not depend on this configuration.
  4. Before starting the tool, run the following query separately on the source and target clusters:
    Start migration only when this query returns no relevant rows on either cluster. This waits for every non-final merge state, including PENDING, PREPARING, RUNNING, CLEANING, and ABORTING. Keep source automatic split enabled so that the source topology can evolve. Do not run independent writes or pre-split operations on the target while migration is active.
The tool reads the actual source and target topology through leader-only ADMIN EXECUTE ON FRONTEND calls. The complete range value for each tablet contains lowerBound, lowerIncluded, upperBound, and upperIncluded. A null endpoint means negative or positive infinity. In a finite multi-column endpoint list, a null cell means SQL NULL; every other cell is a canonical string value. This representation preserves both inclusion flags and distinguishes a literal string NULL from SQL NULL. Although the bridge retains this complete representation for future extension, the current FE-to-BE split path accepts only half-open [lower, upper) child ranges. ADMIN EXECUTE ON FRONTEND is not forwarded to another FE. The tool must discover and connect to each cluster’s Leader FE, and the migration users need the SYSTEM-level OPERATE privilege. FE scripts are privileged code: use a dedicated trusted account, protect its credentials, and pass generated script parameters as properly escaped JSON inside one SQL string. The DDL executor must send the complete ADMIN statement without splitting it at semicolons. After migration, restore the recorded static script-execution setting as described below. For each range-distributed table, the tool compares freshly read source and target topologies. If they differ, the tool stops generating new replication jobs for that table but lets queued, sending, and target-running jobs finish. After all such jobs and replication transactions have drained, it submits an exact-boundary tablet split through the existing DDL queue. Replication resumes only after another topology read proves that source and target ranges are structurally equal. Range distribution does not change shared-data version synchronization. Each replication uses the source physical partition’s visibleVersion, compares the complete metadata and file sets, and skips files that already exist on the target. When transparent data encryption (TDE) is used in shared-data-to-shared-data migration, a newly copied private standalone physical file is read with its source encryption metadata and then re-encrypted under the target policy. If the source key hierarchy cannot be unwrapped, migration fails before the target publication. Newly copied shared or bundled physical files are unsupported when the source file is encrypted or target TDE is enabled. Objects that already exist on the target can be reused directly and retain their target encryption metadata. Migration from a shared-nothing source to a shared-data target fails closed when a source rowset or DCG file is encrypted; decrypting and re-encrypting those files on this path is not supported. Warning This workflow supports split convergence only. It fails closed if convergence would require a target merge, including a source merge, a target-only boundary, crossing ranges, or a target topology finer than the source topology. Range-colocate layouts are also unsupported. After migration, first wait for the tool, replication jobs and transactions, and tablet reshard jobs to drain. Restore dynamic configurations, including the source and target merge setting and the target tablet size, with ADMIN SET FRONTEND CONFIG, and restore their recorded values in fe.conf. Restore automatic reshard behavior only if it was enabled before migration; otherwise keep it disabled. Separately restore the recorded static enable_execute_script_on_frontend value in fe.conf on every FE and restart the FEs. Disable script execution only if its recorded value was false or you intentionally choose a stricter post-migration security policy.

Enable Legacy Compatibility for Replication

The database may behave differently between the old and new versions, causing problems during cross-cluster data migration. Therefore, you must enable Legacy Compatibility for the target cluster before data migration and disable it after data migration is completed.
  1. You can check whether Legacy Compatibility for Replication is enabled by using the following statement:
    If true is returned, it indicates that Legacy Compatibility for Replication is enabled.
  2. Dynamically enable Legacy Compatibility for Replication:
  3. To prevent Legacy Compatibility for Replication from automatically disabling during the data migration process in case of cluster restart, you also need to add the following configuration item in the FE configuration file fe.conf:
Important After the data migration is completed, you need to remove the configuration enable_legacy_compatibility_for_replication = true from the configuration file, and dynamically disable Legacy Compatibility for Replication using the following statement:

Configure Data Migration (Optional)

You can configure data migration operations using the following FE and BE parameters. In most cases, the default configuration can meet your needs. If you wish to use the default configuration, you can skip this step. Note Please note that increasing the values of the following configuration items can accelerate migration but will also increase the load pressure on the source cluster.

FE Parameters

The following FE parameters are dynamic configuration items. Refer to Configure FE Dynamic Parameters on how to modify them.

BE Parameters

The following BE parameter is a dynamic configuration item. Refer to Configure BE Dynamic Parameters on how to modify it.

Step 1: Install the Tool

It is recommended to install the migration tool on the server where the target cluster resides.
  1. Launch a terminal, and download the binary package of the tool.
  2. Decompress the package.

Step 2: Configure the Tool

Navigate to the extracted folder and modify the configuration file conf/sync.properties.
The file content is as follows:
The description of the parameters is as follows: Migrate from Shared-nothing

Obtain Cluster Token

Note The Cluster Token is not required for migration between shared-data clusters. You can skip this step if you want to migrate data between shared-data source clusters. The Cluster Token is stored in <image_dir>/VERSION. Here, <image_dir> is the non-empty image_dir configured in fe.conf, or <meta_dir>/image when image_dir is unset or empty. Log in to the server where the FE node is located, replace <image_dir> with that resolved path, and run the following command:
Output:
Migrate between Shared-data

Map storage volumes

When the migration tool creates a table on the target cluster, it determines the table’s storage volume as follows (in order of precedence):
  1. If target_cluster_use_builtin_storage_volume_only is set to true, builtin_storage_volume is used for all tables.
  2. If target_cluster_storage_volume is set to a specific storage volume, the specified storage volume is used for all tables.
  3. Otherwise, by default, the source table’s storage volume property is reserved. Tables from different source storage volumes are created under the corresponding storage volumes on the target cluster, provided those storage volumes exist on the target.
Therefore, if you want to keep the storage volume property for each table in the source cluster, you can pre-create the same storage volumes in the target cluster. After migration, each table in the target cluster will inherit the storage volume property it had in the source cluster. Note that the src_-prefixed storage volumes serve a different purpose: they are used only during migration to give target CNs read access to the source cluster’s object storage. After migration is complete, the src_<name> volumes are no longer needed and can be dropped. Migrate from Shared-nothing During data migration, the migration tool needs to access all FE nodes of both the source and target clusters, and the target cluster needs to access all BE and CN nodes of the source cluster. You can obtain the network addresses of these nodes by executing the following statements on the corresponding cluster:
If these nodes use private addresses that cannot be accessed outside the cluster, such as internal network addresses within a Kubernetes cluster, you need to map these private addresses to addresses that can be accessed from outside. Navigate to the extracted folder of the tool and modify the configuration file conf/hosts.properties.
The default content of the file is as follows, describing how network address mapping is configured:
Note The <host> must match the address shown in the IP column returned by SHOW FRONTENDS, SHOW BACKENDS, or SHOW COMPUTE NODES. The following example performs these operations:
  1. Map the source cluster’s private network addresses 192.1.1.1 and 192.1.1.2 to 10.1.1.1 and 10.1.1.2.
  2. Map the source cluster’s FE ports 8030 and 9030 to 38030 and 39030 on 10.1.1.1.
  3. Map the target cluster’s private network address fe-0.starrocks.svc.cluster.local to 10.1.2.1 and remap port 9030.
Migrate between Shared-data During data migration, the migration tool needs to access all FE nodes of both the source and target clusters. Note Unlike migration from shared-nothing clusters, you do not need to configure network access from the target cluster to the source cluster’s CN nodes, because data is transferred directly between object storage systems. You can obtain the FE network addresses by executing the following statement on the corresponding cluster:
If FE nodes use private addresses that cannot be accessed outside the cluster, such as internal network addresses within a Kubernetes cluster, you need to map these private addresses to addresses that can be accessed from outside. Navigate to the extracted folder of the tool and modify the configuration file conf/hosts.properties.
The default content of the file is as follows, describing how network address mapping is configured:
Note The <host> must match the address shown in the IP column returned by SHOW FRONTENDS. The following example maps the target cluster’s internal Kubernetes FQDN to a reachable IP:

Synchronize users, roles, and privileges (Optional)

By default, the migration tool does not synchronize account metadata. If you set enable_privilege_sync to true, the tool also synchronizes users, roles, and their privileges from the source cluster to the target cluster. Each time the tool retrieves metadata, it reads the users, roles, and privileges of both clusters, compares them, and executes the DDL statements needed to make the target cluster consistent with the source cluster. User definitions are obtained using SHOW CREATE USER, which returns the password as ciphertext, so no plaintext password is handled during migration. The following objects are never modified by the migration tool:
  • root and the user specified in target_cluster_user. Overwriting the password of the target cluster’s root would lock out its operators, and dropping the account that the tool uses to connect would break the tool’s own connection.
  • The immutable built-in roles root, db_admin, cluster_admin, user_admin, and security_admin. The public role is built-in but mutable, so its privileges are synchronized while the role itself is left alone.
  • The users specified in privilege_sync_exclude_users and the roles specified in privilege_sync_exclude_roles.
Note
  • The FE of both clusters must support SHOW CREATE USER. If the FE of either cluster does not support this statement, users and their privileges are skipped, and only roles and role privileges are synchronized.
  • The progress of privilege synchronization is printed to the log file log/sync.INFO.log with the prefix Sync privilege progress. It lists the status of each of the four units: roles, role privileges, users, and user privileges.
  • In one-time synchronization mode (one_time_run_mode=true), the tool exits successfully only after privileges have also converged. It exits with a failure if either cluster does not support SHOW CREATE USER, or if privileges remain inconsistent across three consecutive comparisons.

Step 3: Start the Migration Tool

After configuring the tool, start the migration tool to initiate the data migration process.
Note
  • If you are migrating data from a shared-nothing cluster, make sure that the BE nodes of the source and target clusters can properly communicate via the network.
  • During runtime, the migration tool regularly checks whether the data in the target cluster is lagging behind the source cluster. If there is a lag, it initiates data migration tasks.
  • If new data is constantly loaded into the source cluster, data synchronization will continue until the data in the target cluster is consistent with that in the source cluster.
  • You can query tables in the target cluster during migration, but do not load new data into the tables, as it may result in inconsistencies between the data in the target cluster and the source cluster. Currently, the migration tool does not forbid data loading into the target cluster during migration.
  • Note that data migration does not automatically terminate. You need to manually check and confirm the completion of migration and then stop the migration tool.

View Migration Progress

View Migration Tool logs

You can check the migration progress through the migration tool log log/sync.INFO.log. Example 1: View task progress. img The important metrics are as follows:
  • Sync job progress: The progress of data migration. The migration tool regularly checks whether the data in the target cluster is lagging behind the source cluster. Therefore, a progress of 100% only means that the data synchronization is completed within the current check interval. If new data continues to be loaded into the source cluster, the progress may decrease in the next check interval.
  • total: The total number of all types of jobs in this migration operation.
  • ddlPending: The number of DDL jobs pending to be executed.
  • jobPending: The number of pending data synchronization jobs to be executed.
  • sent: The number of data synchronization jobs sent from the source cluster but not yet started. Theoretically, this value should not be too large. If the value keeps increasing, please contact our engineers.
  • running: The number of data synchronization jobs that are currently running.
  • finished: The number of data synchronization jobs that are finished.
  • failed: The number of failed data synchronization jobs. Failed data synchronization jobs will be resent. Therefore, in most cases, you can ignore this metric. If this value is significantly large, please contact our engineers.
  • unknown: The number of jobs with an unknown status. Theoretically, this value should always be 0. If this value is not 0, please contact our engineers.
Example 2: View the table migration progress. img
  • Sync table progress: Table migration progress, that is, the ratio of tables that have been migrated in this migration task to all the tables that need to be migrated.
  • finishedTableRatio: Ratio of tables with at least one successful synchronization task execution.
  • expiredTableRatio: Ratio of tables with expired data.
  • total table: Total number of tables involved in this data migration progress.
  • finished table: Number of tables with at least one successful synchronization task execution.
  • unfinished table: Number of tables with no synchronization task execution.
  • expired table: Number of tables with expired data.

View Migration Transaction Status

The migration tool opens a transaction for each table. You can view the status of the migration for a table by checking the status of its corresponding transaction.
<db_name> is the name of the database where the table is located.

View Partition Data Versions

You can compare the data versions of the corresponding partitions in the source and target clusters to view the migration status of that partition.
<table_name> is the name of the table to which the partition belongs.

View Data Volume

You can compare the data volumes in the source and target clusters to view the migration status.

View Table Row Count

You can compare the row counts of tables in the source and target clusters to view the migration status of each table.

After Migration

When Sync job progress has been stable at 100% and your business is ready to switch, complete the cutover as follows:
  1. Stop writes to the source cluster.
  2. Verify Sync job progress reaches and remains at 100% after writes stop.
  3. Stop the migration tool.
  4. Point your applications to the target cluster address.
  5. If you migrated data between shared-data clusters, restore the Auto-Vacuum setting on the source cluster:
  6. If you migrated data between shared-data clusters, re-enable Compaction on the target cluster. Remove lake_compaction_max_tasks = 0 from fe.conf and execute:
  7. Disable Legacy Compatibility for Replication on the target cluster. Remove enable_legacy_compatibility_for_replication = true from fe.conf and execute:

Limits

The list of objects that support synchronization currently is as follows (those not included indicate that synchronization is not supported):
  • Databases
  • Internal tables and their data
  • Materialized view schemas and their building statements (The data in the materialized view will not be synchronized. And if the base tables of the materialized view is not synchronized to the target cluster, the background refresh task of the materialized view reports an error.)
  • Logical views
  • Users, roles, and their privileges (not synchronized by default, enabled by enable_privilege_sync)
For migration between shared-data clusters:
  • The target cluster must be running on v4.1 or later.
  • Migration from a shared-data cluster to a shared-nothing target is not supported.
  • Each storage volume used by the source cluster’s tables must have a corresponding src_<volume_name> storage volume pre-created on the target cluster.