Skip to main content
Beta feature Advice on use of Beta features This topic describes how to use Cluster Snapshot for disaster recovery on shared-data clusters. This feature is supported from v3.4.2 onwards and only available on shared-data clusters.

Overview

In a shared-data cluster, data files are stored in object storage, while FE metadata is stored locally. A cluster snapshot saves an FE metadata image and preserves the data needed to restore the cluster to that point in time. Use a manual snapshot to retain a specific restore point, or use cross-region incremental replication to keep a recovery copy in another region.

Workflow

Workflow

Terms

  • Cluster snapshot A cluster snapshot refers to a snapshot of the cluster state at a certain moment. It contains all the objects in the cluster, such as catalogs, databases, tables, users & privileges, loading tasks, and more. It does not include all external dependent objects, such as configuration files of external catalogs, and local UDF JAR packages.
  • Generating cluster snapshot The system replaces older automated snapshots as new ones complete. You can keep multiple named manual snapshots until you drop them.
  • Cluster Restore Restore the cluster from a snapshot.

Automated cluster snapshot

Automated Cluster Snapshot is disabled by default. Use the following statement to enable this feature: Syntax:
Parameters: INTERVAL <value> <unit>: The interval at which automated snapshots are created. value must be a positive integer, and unit must be one of SECOND, MINUTE, HOUR, DAY, and WEEK. If this parameter is not specified, the interval is controlled by the FE configuration item automated_cluster_snapshot_interval_seconds. storage_volume_name: Specifies the storage volume used to store the snapshot. If this parameter is not specified, the built-in storage volume builtin_storage_volume is used, even if another storage volume is set as the default. If builtin_storage_volume does not exist (for example, because enable_load_volume_from_conf is false), the statement fails, and you must specify a storage volume. For details on creating a storage volume, see CREATE STORAGE VOLUME. snapshot_scope: Use local (the default) for recovery within the same region, or external to replicate data to the specified storage volume for cross-region recovery. Each time the snapshot interval has elapsed since the previous automated snapshot started, the Leader FE performs a metadata checkpoint to create a new metadata image, and creates a snapshot from it. The name of the snapshot is generated by the system, following the format automated_cluster_snapshot_{timestamp}. Metadata snapshots are stored under /{storage_volume_locations}/{service_id}/meta/image/automated_cluster_snapshot_timestamp. With snapshot_scope=local, data files stay in their original location. FE configuration item automated_cluster_snapshot_interval_seconds controls the snapshot automation cycle when no INTERVAL is specified for the feature. The default value is 600 seconds (10 minutes). Use the following statement to change the interval while the feature is enabled (supported from v4.0.5 onwards, as is the INTERVAL clause):
Use the following statement to view whether the feature is enabled, the effective interval, the storage volume, and the time of the last and the next snapshot (supported from v4.0.6 onwards):

Disable automated cluster snapshot

Use the following statement to disable automated cluster snapshot:
Disabling automated snapshots removes local automated snapshots and retains the latest completed external snapshot if the scope was external.

Cross-region incremental replication

Cross-region incremental replication supports only external automated snapshots (snapshot_scope=external). Create the destination storage volume in the recovery region and make sure the source cluster can write to it. If automated snapshots are already enabled, disable them before enabling them with the new scope and destination.
The first successful run copies the data files referenced by the snapshot. Subsequent runs copy only the new or changed data files and write a complete FE metadata image each time. Each completed snapshot can be used for cross-region recovery. Before using the snapshot, query information_schema.cluster_snapshot_jobs and confirm that the job’s state is FINISHED. Before a recovery, record the completed snapshot’s storage_path from information_schema.cluster_snapshots. Use that full URI in the cross-region recovery configuration.

Manual cluster snapshot

Create a named snapshot before a change for which you want to retain a restore point. The example writes the snapshot to the existing storage volume snapshot_volume.
Wait for the job to reach FINISHED. To recover the entire cluster, see Restore the cluster. To recover one table, see Restore a table from a manual snapshot. Drop the manual snapshot with DROP CLUSTER SNAPSHOT before_upgrade when you no longer need it. The FE parameter max_manual_cluster_snapshot_jobs controls how many manual snapshots can be retained (default 50).

Cross-region limits for manual snapshots

Manual snapshots always use local scope. Even when STORAGE VOLUME points to a remote volume, the snapshot job writes only metadata to that volume. The underlying data files stay in their original storage, so the metadata alone is insufficient for cross-region recovery.

Restore a table from a manual snapshot

On the same shared-data cluster, restore a table from a completed snapshot into a new table. The destination database must exist and the destination table must be absent. For example, restore sales.orders as it was at before_upgrade into sales.orders_restored.
The restore runs asynchronously. Run SHOW RESTORE FROM sales to check the job status.

View cluster snapshot

You can query the view information_schema.cluster_snapshots to view the latest cluster snapshot and the snapshots yet to be dropped.
Return:

View cluster snapshot job

You can query the view information_schema.cluster_snapshot_jobs to view the job information of cluster snapshots.
Return:

Restore the cluster

Follow these steps to restore the cluster with the cluster snapshot.
  1. To select a named snapshot or recover into a different cluster, configure cluster_snapshot.yaml in the Leader FE’s fe/conf directory.
    • Named manual snapshot. Start with the Appendix template. Set cluster_snapshot.cluster_snapshot_path to the full snapshot directory URI from storage_path in information_schema.cluster_snapshots. Set cluster_snapshot.storage_volume_name to the snapshot’s storage volume and include that volume in storage_volumes. A path ending in /meta selects an automated snapshot.
    • Cross-cluster recovery within a region. Use the Appendix template. If the target cluster uses a new storage path, copy all files under the original storage path to the new one.
    • Cross-region recovery from an external snapshot. Use the cross-region recovery configuration to read the completed snapshot and map the recovered cluster’s writable storage.
  2. Start the Leader FE node.
  3. Start other FE nodes after cleaning the meta directories.
    Add the nodes to the cluster.
  4. Start CN nodes after cleaning the storage_root_path directories.
    Add the node to the cluster.
If you have modified cluster_snapshot.yaml in the step 1, the node and storage volumes will be re-configured in the new cluster according to the information in the file.

Appendix

Template of cluster_snapshot.yaml for cross-cluster recovery:
Note For more information on credentials for AWS, see Authenticate to AWS S3.

Cross-region recovery configuration

The following fe/conf/cluster_snapshot.yaml example uses S3 in the recovery region. Replace <completed_external_snapshot_uri> with the storage_path of a finished external snapshot. The target cluster needs read access to snapshot_storage_volume and write access to the locations in storage_volumes. This example uses the AWS SDK default credential chain.
The example assumes the source snapshot contains source_data_volume and dr_volume. Include all source storage volume names from your snapshot in storage_volumes and give each a writable location separate from the snapshot location. With the configuration in place, continue with the Leader FE startup step under Restore the cluster.

Limitations

  • Currently, standby mode is not supported. The primary and secondary clusters cannot be online simultaneously. Otherwise, the normal operation of the secondary cluster cannot be guaranteed.
  • Currently, only one automated cluster snapshot can be retained.