After a restore succeeds, all restored tenants are standby tenants. You can execute the RECOVER command to continue replaying logs from the log archive source specified during the tenant restore.
Background information
A tenant restored by using physical restore serves as a standby tenant. Subsequently, 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 has succeeded. For more information about how to view the restore result, see View the result of physical restore.
Specify log replay for a standby tenant from the sys tenant
Log in to the
systenant of the cluster as therootuser.Execute the following statements to replay logs:
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 of a user tenant is the
rootuser.Execute the following statements to replay logs:
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;