This topic describes how to perform tenant-level physical restore by using commands. Currently, OceanBase AI Database supports tenant-level full restore to a point in time. For more information about full restore, see Overview of physical backup and restore.
You can restore a tenant in the same cluster or in a different cluster in OceanBase AI Database.
The restore process first restores the required macroblocks from the corresponding full backup to the target tenant based on the commands you enter. It then synchronously pulls and replays the transaction logs.
Prerequisites
Before you perform a physical restore, make sure that all preparations are complete. For more information, see Preparations before restore.
Precautions
- In addition to data, tenant-level configuration items are backed up during data backup. However, the backed-up tenant-level configuration items are provided only as configuration references and are not directly restored to the tenant during physical restore. For more information about backing up parameters, see Back up parameters.
Procedure
Log in to the
systenant of the cluster as therootuser.(Optional) Execute the following statement to set the restore password for the backup.
The restore password is required only if a password was added during data backup.
SET DECRYPTION IDENTIFIED BY 'password';Replace
passwordwith the password added during backup.Here is an example:
SET DECRYPTION IDENTIFIED BY '******';Execute the following statement to set the encryption information.
Note
If the data is not encrypted or the original Key Management Service can be accessed during restore, skip this step.
obclient [(none)]> SET @kms_encrypt_info = '<encryption_string>';Here,
<encryption_string>is the value ofEXTERNAL_KMS_INFO, which is a tenant-level configuration item.Note
external_kms_infois used to store key management information. For more information about this configuration item, see external_kms_info.Execute the following statement to start a restore task.
Restore to a specified timestamp
ALTER SYSTEM RESTORE dest_tenant_name FROM uri UNTIL TIME='timestamp' WITH 'pool_list=pool_list[&locality=locality][&primary_zone=zone_name][&concurrency=int_num][&kms_encrypt={true | false}][&method=full]' [WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password'] [DESCRIPTION description];Restore to a specified SCN
ALTER SYSTEM RESTORE dest_tenant_name FROM uri UNTIL SCN=scn WITH 'pool_list=pool_list[&locality=locality][&primary_zone=zone_name][&concurrency=int_num][&kms_encrypt={true | false}][&method=full]' [WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password'] [DESCRIPTION description];Restore to the latest timestamp
ALTER SYSTEM RESTORE dest_tenant_name FROM uri WITH 'pool_list=pool_list[&locality=locality][&primary_zone=zone_name][&concurrency=int_num][&kms_encrypt={true | false}][&method=full]' [WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password'] [DESCRIPTION description];
The parameters in the statements are described as follows:
TIME='timestamp'andSCN=scn: Specifies the end point for restore. Data is restored to this point, including the point. For more information about how to specifyTIMEorSCN, see Introduction to physical restore parameters.uri: Specifies the data backup pathbackup_data_destand the log archive pathlog_archive_destspecified during backup. At least one data backup path and one log archive path must be specified, and they are separated by commas (,).pool_list: Specifies the resource pools for the user. Multiple resource pools are separated by commas (,).localityandprimary_zone: Optional. Specifies the locality information for the new tenant replica distribution and the preferred location for the leader replica. For more information about these parameters, see RESTORE.concurrency: Optional. Specifies the concurrency for data restore. The default value is theMAX_CPUvalue of the units allocated to the tenant.kms_encrypt: Optional. Specifies whether to use thekms_encrypt_infospecified before restore.method: Optional. Specifies the restore method. The value is case-insensitive. Valid values:full: Full restore. If this parameter is not specified, the default value isfull.
WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password': Specifies the key backup information for the encrypted tenant. Specify the key backup information only if transparent encryption is configured for the source tenant.backup_key_path: The backup path of the key.password: The encryption password set when backing up the key.
For more information about key backup, see Back up the key in Prepare for backup.
For more information about the parameters of physical restore, see RESTORE.
Here are some restore examples:
AWS S3Object storage compatible with the S3 protocolRestore the
mysqltenant from the S3 backup path and S3 log archive path to the specified timestamp2024-01-15 00:00:00. Specify the resource pool asrestore_pooland perform a full restore.ALTER SYSTEM RESTORE mysql FROM 's3://oceanbase-test-bucket/backup/data?host=s3.<region>.amazonaws.com&access_id=***&access_key=***&s3_region=***, s3://oceanbase-test-bucket/backup/archive?host=s3.<region>.amazonaws.com&access_id=***&access_key=***&s3_region=***' UNTIL TIME='2024-01-15 00:00:00' WITH 'pool_list=restore_pool';Restore the
mysqltenant from the OBS backup path and log archive path to the specified timestamp2023-06-01 00:00:00. Specify the resource pool asrestore_pooland perform a full restore.obclient> ALTER SYSTEM RESTORE mysql FROM 's3://oceanbase-test-bucket/backup/data/?host=obs.***.myhuaweicloud.com&access_id=***&access_key=***,s3://oceanbase-test-bucket/backup/archive/?host=obs.***.myhuaweicloud.com&access_id=***&access_key=***' UNTIL TIME='2023-06-01 00:00:00' WITH 'pool_list=restore_pool';Restore the
mysqltenant from the GCS backup path and log archive path to the specified timestamp2023-06-01 00:00:00. Specify the resource pool asrestore_pooland perform a full restore.obclient> ALTER SYSTEM RESTORE mysql FROM 's3://oceanbase-test-bucket/backup/data/?host=https://storage.googleapis.com&access_id=***&access_key=***,s3://oceanbase-test-bucket/backup/archive/?host=https://storage.googleapis.com&access_id=***&access_key=***' UNTIL TIME='2023-06-01 00:00:00' WITH 'pool_list=restore_pool';Restore the
mysqltenant from the COS backup path and log archive path to the specified timestamp2023-06-01 00:00:00. Specify the resource pool asrestore_pooland perform a full restore.obclient> ALTER SYSTEM RESTORE mysql FROM 's3://oceanbase-test/backup/data?host=cos.ap-xxxx.myqcloud.com&access_id=***&access_key=***,s3://oceanbase-test/backup/archive?host=cos.ap-xxxx.myqcloud.com&access_id=***&access_key=***' UNTIL TIME='2023-06-01 00:00:00' WITH 'pool_list=restore_pool';
(Optional) After the Meta tenant corresponding to the tenant to be restored is created, if you need to accelerate the restore, you can configure the number of concurrent threads for the restore task by using the
ha_high_thread_scoreconfiguration item.Query the
oceanbase.DBA_OB_TENANTSview to check whether the Meta tenant corresponding to the tenant to be restored has been created.A sample query is as follows:
obclient> SELECT * FROM oceanbase.DBA_OB_TENANTS;In the query result, the tenant whose
TENANT_NAMEcolumn starts withMETA$is the Meta tenant. When the status of the Meta tenant isNORMAL, it indicates that the Meta tenant has been created successfully.For more information about the columns in the
DBA_OB_TENANTSview, see DBA_OB_TENANTS.Set the
ha_high_thread_scoreconfiguration item.The tenant-level configuration item
ha_high_thread_scorespecifies the current number of worker threads for high availability high-priority threads. The default value is 0, and the value range is [0, 100]. We recommend that you set it to 10. For more information aboutha_high_thread_score, see ha_high_thread_score.The statement is as follows:
obclient> ALTER SYSTEM SET ha_high_thread_score =10 TENANT = mysql;
What to do next
After initiating a restore task, you can view the progress and results of the restore in views. For more information, see View the physical restore progress.
After the restore task is completed, if you are restoring from backup data of a lower version to a cluster of a higher version, you also need to upgrade the restored tenant. For more information, see Upgrade a tenant after restore is complete.
A tenant after physical restore is a standby tenant. Subsequently, this tenant can provide services as a standby tenant or be converted to a primary tenant to provide services. For more information about how to continue log archiving and replay logs from the source tenant as a standby tenant, see Segment-based log replay for a standby tenant; for more information about how to convert a standby tenant into a primary tenant, see Convert a standby tenant into a primary tenant.