You can create a standby tenant only by using the physical restore feature. To create a standby tenant, perform the following two steps: restore the standby tenant by using data backups and archive logs, and then change the recovery endpoint of the standby tenant.
Prerequisites
A standby tenant can be restored only by using the data backups and archive logs of the primary tenant and another standby tenant. Therefore, you must make sure that the following requirements are met before you create a standby tenant:
To restore a standby tenant by using the data backups and archive logs of the primary tenant, make sure that:
Archivelog is enabled for the primary tenant, and log archiving remains in the
DOINGstate.For more information about how to enable archivelog, see Enable archivelog. For more information about how to view the log archiving status, see View the archiving progress.
Notice
To ensure that all logs during data backup are archived, you must enable archivelog for the primary tenant before you start data backup.
The data backup feature is enabled for the primary tenant and a full backup operation has been completed for the primary tenant.
For more information about how to initiate full backup of a tenant, see Initiate a data backup job.
To restore a standby tenant by using the data backups and archive logs of another standby tenant, make sure that:
Archivelog is enabled for the source standby tenant, and log archiving remains in the
DOINGstate.For more information about how to enable archivelog, see Enable archivelog. For more information about how to view the log archiving status, see View the archiving progress.
Notice
To ensure that all logs during data backup are archived, you must enable archivelog for the source standby tenant before you start data backup.
The data backup feature is enabled for the source standby tenant and a full backup operation has been completed for the source standby tenant.
For more information about how to initiate full backup of a tenant, see Initiate a data backup job.
Restore a standby tenant
Log on to the
systenant of the cluster where you want to create a standby tenant.Execute the
RESTOREstatement to restore the standby tenant by using the data backups and archive logs of the sys tenant.Syntax:
ALTER SYSTEM RESTORE standby_tenant_name FROM uri UNTIL TIME =timestamp WITH restore_option [DESCRIPTION description];The parameters are as follows:
standby_tenant_name: the name of the standby tenant to be restored.uri: the path of data backups and the path of archive logs of the primary tenant or an existing standby tenant.UNTIL TIME =timestamp: the recovery endpoint, which is the timestamp to which the standby tenant is restored. Join the parameter name and the value oftimestampwith an equal sign (=). The value oftimestampmust be in theYYYY-MM-DD HH24:MI:SS.FFformat, accurate to nanoseconds. For more information about to selecttimestamp, see Parameters related to physical restore.In
restore_option, you can specifypool_list,locality,primary_zone, andkms_encrypt.pool_listis required and the others are optional.
Restore the
restore_oracle_tenanttenant to the specified timestamp of2022-11-11 15:04:23.825558by using the logs archived infile:///data/1/nfs/backup//ob_backup_oracle_tenant/archiveand the data backups stored infile:///data/1/nfs/backup//ob_backup_oracle_tenant/data. Set the resource pool tosmall_pool_2andprimary_zonetoz1.Sample statement:
ALTER SYSTEM RESTORE oracle_standby FROM 'file:///data/1/nfs/backup//ob_backup_oracle_tenant/archive,file:///data/1/nfs/backup//ob_backup_oracle_tenant/data' UNTIL TIME='2022-11-11 15:04:23.825558' with 'pool_list=small_pool_2&primary_zone=z1';For more information about the
RESTOREstatement, see Parameters related to physical restore.You can query the
oceanbase.CDB_OB_RESTORE_PROGRESSview for the restore progress. For more information, see Query the restore progress.
Change the recovery endpoint of the new standby tenant
The new standby tenant does not continuously synchronize the archive logs of the primary or source standby tenant. You must set the recovery endpoint of the new standby tenant by using the RECOVER statement.
Log on to the database as the administrator of the new standby tenant or the
systenant of the cluster where the new standby tenant resides.Execute the
RECOVERstatement to change the recovery endpoint of the standby tenant based on your actual business.Restore to a specified timestamp
ALTER SYSTEM RECOVER STANDBY [TENANT = tenant_name] UNTIL TIME='timestamp';You need to specify the name of the standby tenant by adding the
TENANT = tenant_nameparameter in the statement only if you execute the statement in thesystenant. Thetimestampparameter specifies the timestamp, in nanoseconds, to which the standby tenant is restored.After you execute this statement, the standby tenant is restored to the specified timestamp.
Restore to a specified SCN
ALTER SYSTEM RECOVER STANDBY [TENANT = tenant_name] UNTIL SCN=scn;You need to specify the name of the standby tenant by adding the
TENANT = tenant_nameparameter in the statement only if you execute the statement in thesystenant. Thescnparameter specifies the system change number (SCN), which is a logical internal timestamp.After you execute this statement, the standby tenant is restored to the specified timestamp.
Restore to an infinite endpoint
ALTER SYSTEM RECOVER STANDBY [TENANT = tenant_name] UNTIL UNLIMITED;You need to specify the name of the standby tenant by adding the
TENANT = tenant_nameparameter in the statement only if you execute the statement in thesystenant.UNLIMITEDindicates that the recovery endpoint is infinite.After you execute this statement, the standby tenant enters the continuous synchronization mode.