After a restore succeeded, the restored tenant is a standby tenant. You can execute the RECOVER statement to continue replaying logs from the log archive source specified during the tenant restore.
Background information
The physical restore process is integrated with the physical standby database. A tenant restored by using physical restore serves as a standby tenant. Later, the tenant can provide services as a standby tenant or be converted into the primary tenant to provide services.
Prerequisites
Make sure that the restore operation has succeeded. For more information about how to check the restore result, see Check the restore result.
Specify log replay for a standby tenant from the sys tenant
Log in to the
systenant of the cluster as therootuser.Execute the following statement to replay logs.
The statement is as follows:
Replay logs to the specified timestamp, including the point at the specified timestamp.
obclient [(none)]> ALTER SYSTEM RECOVER STANDBY TENANT tenant_name UNTIL TIME='timestamp';Replay logs to the specified SCN, including the point at the specified SCN.
obclient [(none)]> ALTER SYSTEM RECOVER STANDBY TENANT tenant_name UNTIL SCN=scn;Continuously replay logs from the archive source without specifying an end point.
obclient [(none)]> ALTER SYSTEM RECOVER STANDBY TENANT tenant_name UNTIL UNLIMITED;Note
This statement allows you to specify only one standby tenant at a time. To perform this operation on multiple tenants, execute this statement repeatedly.
After the statement is successfully executed, if you want to cancel the log replay for the standby tenant, execute the following statement.
obclient [(none)]> ALTER SYSTEM RECOVER STANDBY TENANT tenant_name CANCEL;Check the log replay progress of the standby tenant.
obclient(root@sys)[oceanbase]> SELECT TENANT_ID, LS_ID, STATUS, READABLE_SCN FROM oceanbase.CDB_OB_LS WHERE TENANT_ID=xxx;If you need to check the timestamp to which logs are replayed, you can use the
SCN_TO_TIMESTAMPfunction to convert it. The statement is as follows:obclient(root@sys)[oceanbase]> SELECT TENANT_ID, LS_ID, STATUS, SCN_TO_TIMESTAMP(READABLE_SCN) FROM oceanbase.CDB_OB_LS WHERE TENANT_ID=xxx;
Initiate log replay from a standby tenant
A standby tenant can also initiate its own log replay.
Log in to the database as the tenant administrator of a user tenant.
Note
The administrator user is
rootfor a MySQL tenant andSYSfor an Oracle tenant.Execute the following statement to replay logs.
The statement is as follows:
Replay logs to the specified timestamp, including the point at the specified timestamp.
obclient [(none)]> ALTER SYSTEM RECOVER STANDBY UNTIL TIME='timestamp';Replay logs to the specified SCN, including the point at the specified SCN.
obclient [(none)]> ALTER SYSTEM RECOVER STANDBY UNTIL SCN=scn;Continuously replay logs from the archive source without specifying an end point.
obclient [(none)]> ALTER SYSTEM RECOVER STANDBY UNTIL UNLIMITED;Note
This statement allows you to specify only one standby tenant at a time. To perform this operation on multiple tenants, execute this statement repeatedly.
After the statement is successfully executed, if you want to cancel the log replay for the standby tenant, execute the following statement.
obclient> ALTER SYSTEM RECOVER STANDBY CANCEL;Check the log replay progress of the standby tenant.
obclient> SELECT LS_ID, STATUS, READABLE_SCN FROM oceanbase.DBA_OB_LS;If you need to check the timestamp to which logs are replayed, you can use the
SCN_TO_TIMESTAMPfunction to convert it. The statement is as follows:obclient> SELECT LS_ID, STATUS, SCN_TO_TIMESTAMP(READABLE_SCN) FROM oceanbase.DBA_OB_LS;
