This topic describes how to perform tenant-level physical restore by using an SQL statement. OceanBase Database supports tenant-level full restore based on points in time.
After you execute the restore statement, the system restores the required macroblock data from the corresponding full and incremental backups at the backup destination to the destination tenant and then pulls and replays the transaction logs.
Prerequisites
The preparations before the restore are complete. For more information, see Preparations.
Procedure
Log on to the
systenant of the cluster as therootuser.(Optional) Execute the following statement to set a restore password for the backup.
You need to set a restore password for the backup only if a password is added during data backup.
obclient [(none)]> SET DECRYPTION IDENTIFIED BY 'password';In the statement,
passwordmust be replaced with the password added during data backup. If the password for full backup is different from the password for incremental backup, you must enter the password for full before the password for incremental backup and separate them with a comma.For example:
obclient [(none)]> SET DECRYPTION IDENTIFIED BY '******'; obclient [(none)]> SET DECRYPTION IDENTIFIED BY '******','******';Execute the following statement to start a restore job:
Restore to a specified timestamp
obclient [(none)]> ALTER SYSTEM RESTORE dest_tenant_name FROM uri UNTIL TIME=timestamp WITH restore_option [DESCRIPTION description];Restore to a specified SCN
obclient [(none)]> ALTER SYSTEM RESTORE dest_tenant_name FROM uri UNTIL SCN=scn WITH restore_option [DESCRIPTION description];Restore to the latest checkpoint
obclient [(none)]> ALTER SYSTEM RESTORE dest_tenant_name FROM uri WITH restore_option [DESCRIPTION description];urispecifies the data backup path and log archive path, andUNTIL [TIME|SCN]specifies the end checkpoint for restore.To restore to a specified
TIMEorSCN, you must join the parameter name and value with an equal sign (=).In
restore_option, you can specifypool_list,locality,primary_zone, andkms_encrypt.pool_listis required and the others are optional.
For more information about
TIME,SCN, and other parameters, see Parameters related to physical restore.Here are some examples:
NFS
Restore the
mysqltenant from the data backup pathfile:///data/nfs/backup/dataand log archive pathfile:///data/nfs/backup/archiveto the specified timestamp2020-06-01 00:00:00, and set the resource pool torestore_pool.obclient [(none)]> ALTER SYSTEM RESTORE mysql FROM 'file:///data/nfs/backup/data,file:///data/nfs/backup/archive' UNTIL TIME='2020-06-01 00:00:00' WITH 'pool_list=restore_pool';Restore the
mysqltenant from the data backup pathfile:///data/nfs/backup/dataand log archive pathfile:///data/nfs/backup/archiveto the latest archive checkpoint, and set the resource pool torestore_pool.obclient [(none)]> ALTER SYSTEM RESTORE mysql FROM 'file:///data/nfs/backup/data,file:///data/nfs/backup/archive' WITH 'pool_list=restore_pool';Restore the
mysqltenant from the data backup pathfile:///data/nfs/backup/dataand log archive pathfile:///data/nfs/backup/archiveto the specified SCN1658285759724047000, and set the resource pool torestore_pool.obclient [(none)]> ALTER SYSTEM RESTORE mysql FROM 'file:///data/nfs/backup/data,file:///data/nfs/backup/archive' UNTIL SCN=1658285759724047000 WITH 'pool_list=restore_pool';Restore the
mysqltenant from the data backup pathfile:///data/nfs/backup/dataand log archive pathfile:///data/nfs/backup/archiveto the specified timestamp2020-06-01 00:00:00. Set the resource pool torestore_pooland the locality of replicas toF@z1,F@z2,F@z3.obclient [(none)]> ALTER SYSTEM RESTORE mysql FROM 'file:///data/nfs/backup/data,file:///data/nfs/backup/archive' UNTIL TIME='2020-06-01 00:00:00' WITH 'pool_list=restore_pool&locality=F@z1,F@z2,F@z3';Restore the
mysqltenant from the data backup pathfile:///data/nfs/backup/dataand log archive pathfile:///data/nfs/backup/archiveto the specified timestamp2020-06-01 00:00:00. Set the resource pool torestore_pool, the locality of replicas toF@z1,F@z2,F@z3, andprimary_zonetoz1.obclient [(none)]> ALTER SYSTEM RESTORE mysql FROM 'file:///data/nfs/backup/data,file:///data/nfs/backup/archive' UNTIL TIME='2020-06-01 00:00:00' WITH 'pool_list=restore_pool&locality=F@z1,F@z2,F@z3&primary_zone=z1';
Object Storage Service (OSS)
Except for the
urlparameter, the settings of other parameters are consistent with those whenNFSis used.Restore the
mysqltenant from the OSS backup pathoss://oceanbase-test-bucket/backup/data/?host=xxx.aliyun-inc.com&access_id=xxx&access_key=xxxand OSS log archive pathoss://oceanbase-test-bucket/backup/archive/?host=xxx.aliyun-inc.com&access_id=xxx&access_key=xxxto the specified timestamp2020-06-01 00:00:00, and set the resource pool torestore_pool.obclient [(none)]> ALTER SYSTEM RESTORE mysql FROM 'oss://oceanbase-test-bucket/backup/data/?host=xxx.aliyun-inc.com&access_id=xxx&access_key=xxx,oss://oceanbase-test-bucket/backup/archive/?host=xxx.aliyun-inc.com&access_id=xxx&access_key=xxx' UNTIL TIME='2020-06-01 00:00:00' WITH 'pool_list=restore_pool';
(Optional) After you create the meta tenant corresponding to the tenant to be restored, set the
ha_low_thread_scoreparameter to specify the backend scheduling weight for the restore task to speed up the restore.Query the
oceanbase.DBA_OB_TENANTSview to check whether the meta tenant is created.obclient [(none)]> SELECT * FROM oceanbase.DBA_OB_TENANTS;In the query results, tenant names starting with
META$in theTENANT_NAMEcolumn indicate meta tenants. Meta tenants in theTENANT_STATUS_NORMALstate are successfully created.Specify the
ha_high_thread_scoreparameter.The tenant-level
ha_high_thread_scoreparameter specifies the current number of high-availability worker threads with a high priority. Default value:0. Value range: [0, 100]. We recommend that you set this parameter to10. For more information about theha_high_thread_scoreparameter, see ha_high_thread_score.Sample statement:
obclient [(none)]> ALTER SYSTEM SET ha_high_thread_score =10 TENANT = mysql;
What to do next
After you initiate a restore job, you can query the corresponding views to check the restore progress and results. For more information, see Query the restore progress.
Physical restore is associated with Physical Standby Database. A physically restored tenant serves as a standby tenant. You can change its role to PRIMARY based on your business needs. For more information about how to proceed to log replay from the source tenant, see Replay logs to a standby tenant. For more information about how to change the role of a standby tenant to PRIMARY, see Change the role of a standby tenant to PRIMARY.