主庫與備庫之間的網路,因為電信維修,所以中斷連線。在網路恢復之後,卻沒有正常的恢復同步。
檢查備庫的alert log,發現有下列的錯誤:
Media Recovery Waiting for thread 1 sequence 72754
Fetching gap sequence in thread 1, gap sequence 72754-72756
Mon Aug 02 19:52:33 2021
FAL[client]: Failed to request gap sequence
GAP - thread 1 sequence 72754-72756
DBID 259219464 branch 847381128
FAL[client]: All defined FAL servers have been attempted.
------------------------------------------------------------
Check that the CONTROL_FILE_RECORD_KEEP_TIME initialization
parameter is defined to a value that's sufficiently large
enough to maintain adequate log switch information to resolve
archivelog gaps.
------------------------------------------------------------
在備庫執行下列的SQL,可以查詢gap的缺少的日誌
SQL> select * from v$archive_gap;
THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
------- ------------- --------------
1 72754 72756
發生原因在於備庫於主庫中找不到對應的日誌72754、72756,因為我事前已先將archive log移至DataDomain暫存,所以主庫上當然找不到這些檔案。
先將archive log(72754、72755、72756)由Datadomain中複製到備庫中,再將它們註冊到備庫中,備庫就會開始恢復它們。
SQL> ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/PROD_72754.arc';
如果需要恢復的日誌檔很多,則可以改用下列的SQL來產生語法:
select 'ALTER DATABASE REGISTER PHYSICAL LOGFILE ''/tmp/'||substr(name,35)||''';' from v$archived_log where SEQUENCE#>=72754 and SEQUENCE#<=72756 and thread#=1 and NAME<>'standby service name';
將缺少的日誌都補上後,備庫就可以正常與主庫同步了。
附上scp的語法,記錄一下:
scp 來源檔案 <遠端帳號>@<遠端伺服器>:<遠端目錄>
例:scp PROD_72832.arc PROD_72833.arc <USER>@<SERVER>:<PATH>