乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      實戰(zhàn)篇:Oracle DataGuard 出現(xiàn) GAP 修復(fù)完整步驟

       LuciferLiu 2021-12-10

      前言

      DG GAP 顧名思義就是:DG不同步,當(dāng)備庫不能接受到一個或多個主庫的歸檔日志文件時候,就發(fā)生了 GAP。

      那么,如果遇到GAP如何修復(fù)呢?且聽我細細道來~

      一、介紹

      DG GAP 主要分為以下兩類情況:

      1、主庫歸檔日志存在,可以通過配置 Fetch Archive Log(FAL) 參數(shù),自動解決歸檔 GAP。
      2、主庫歸檔日志丟失,需要 人工干預(yù) 來修復(fù)。

      不同 Oracle 版本的 GAP 修復(fù)方式也不盡相同,下面分別介紹不同版本的方式!

      11G 的處理步驟:

      a.在主庫上創(chuàng)建一個備庫的控制文件
      b.以備庫的當(dāng)前SCN號為起點,在主庫上做一個增量備份
      c.將增量備份拷貝到備庫上
      d.使用新的控制文件將備庫啟動到mount狀態(tài)
      e.將增量備份注冊到RMAN的catalog,取消備庫的恢復(fù)應(yīng)用,恢復(fù)增量備份
      f.開啟備庫的恢復(fù)進程

      12C 的新特性(RECOVER … FROM SERVICE)

      18C 的新特性(RECOVER STANDBY DATABASE FROM SERVICE)

      Oracle隨著版本的升級,逐漸將步驟縮減,進行封裝,18C之后可謂是達到了所謂的一鍵刷新,恢復(fù)DG同步。

      二、實戰(zhàn)

      下面我們通過實驗來進行演示如何修復(fù):

      • 11G常規(guī)修復(fù)
      • 12C新特性(RECOVER … FROM SERVICE)修復(fù)
      • 18C新特性(RECOVER STANDBY DATABASE FROM SERVICE)修復(fù)

      安裝測試環(huán)境可以使用博主編寫的 Oracle 一鍵安裝腳本,同時支持單機和 RAC 集群模式!

      開源項目:Install Oracle Database By Scripts!

      更多更詳細的腳本使用方式可以訂閱專欄:Oracle一鍵安裝腳本

      三、11G常規(guī)修復(fù)

      首先,模擬備庫斷電,主庫切幾個最新的歸檔,然后手工刪掉,重新開啟DG同步。

      備庫停止DG同步進程:

      sqlplus / as sysdba
      ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
      shutdown immediate
      

      主庫切換多次歸檔:

      sqlplus / as sysdba
      alter system switch logfile;
      

      主庫刪除最近幾個歸檔日志:

      rm 1_34_1070147137.arc 
      rm 1_33_1070147137.arc
      

      備庫開啟同步進程:

      startup
      ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
      

      查看GAP:

      sqlplus / as sysdba
      SELECT * FROM V$ARCHIVE_GAP;
      THREAD#    LOW_SEQUENCE# HIGH_SEQUENCE#
      ---------- ------------- --------------
       1   32  34
      
      SELECT max(sequence#) from v$archived_log where applied='YES';
      MAX(SEQUENCE#)
      --------------
      31
      

      📢 注意: 當(dāng)前DG數(shù)據(jù)庫已存在GAP,GAP日志為:32—34。

      a.在主庫上創(chuàng)建一個備庫的控制文件

      alter database create standby controlfile as '/tmp/standby.ctl';
      

      b.以備庫的當(dāng)前SCN號為起點,在主庫上做一個增量備份

      備庫查詢當(dāng)前 scn 號:

      sqlplus / as sysdba
      select  to_char(current_scn) from v$database;
      TO_CHAR(CURRENT_SCN)
      ----------------------------------------
      1086639
      

      確認主備GAP期間是否新增數(shù)據(jù)文件:

      sqlplus / as sysdba
      select file# from v$datafile where creation_change# > =1086639;
      

      主庫根據(jù)備庫scn號進行增量備份:

      rman target /
      run{
      allocate channel c1 type disk;
      allocate channel c2 type disk;
      backup INCREMENTAL from scn 1086639 database format '/tmp/incre_%U';
      release channel c1;
      release channel c2;
      }
      

      📢 注意: 如果存在新增數(shù)據(jù)文件,備庫恢復(fù)時需要先restore新添加的數(shù)據(jù)文件。

      c.將增量備份和控制文件拷貝到備庫上

      主庫拷貝增量備份和控制文件你至備庫:

      scp incre_0* oracle@orcl_stby:/home/oracle
      scp standby.ctl oracle@orcl_stby:/home/oracle
      

      📢 注意: 確認備庫的磁盤空間是否足夠存放。

      d.使用新的控制文件將備庫啟動到mount狀態(tài)

      備庫關(guān)閉數(shù)據(jù)庫實例,開啟至nomount狀態(tài):

      sqlplus / as sysdba
      shutdown immediate
      startup nomount
      

      備庫恢復(fù)新的控制文件:

      rman target /
      restore controlfile from '/home/oracle/standby.ctl';
      

      備庫開啟到mount狀態(tài):

      alter database mount;
      

      e.增量備份注冊到RMAN的catalog,取消日志應(yīng)用,恢復(fù)增量備份

      確認備庫已關(guān)閉DG同步進程:

      sqlplus / as sysdba
      ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
      

      備庫rman注冊增量備份文件:

      rman target /
      catalog start with '/home/oracle/';
      YES
      

      備庫開啟恢復(fù)增量備份:

      recover database noredo;
      

      f.開啟備庫的恢復(fù)進程

      備庫開啟日志同步進程:

      sqlplus / as sysdba
      alter database open read only;
      ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
      

      主庫重新激活同步:

      sqlplus / as sysdba
      ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=defer;
      ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=enable;
      

      查詢是否存在GAP,確認主備是否同步:

      sqlplus / as sysdba
      SELECT * FROM V$ARCHIVE_GAP;
      SELECT max(sequence#) from v$archived_log where applied='YES';
      SELECT PROCESS, STATUS, THREAD#, SEQUENCE#, BLOCK#, BLOCKS FROM V$MANAGED_STANDBY;
      

      至此,DG GAP已被修復(fù),以上方式為常規(guī)修復(fù)方式,各個版本都通用。

      四、12C新特性修復(fù)

      首先,模擬備庫斷電,主庫切幾個最新的歸檔,然后手工刪掉,重新開啟DG同步。

      模擬GAP期間,有數(shù)據(jù)文件添加的情況:

      ##主庫添加數(shù)據(jù)文件
      alter tablespace TEST add datafile '/oradata/ORCL/test02.dbf' size 100M autoextend off;
      

      📢 注意: 當(dāng)前DG數(shù)據(jù)庫已存在GAP,GAP日志為:30—31 。

      a.記錄備庫當(dāng)前SCN號

      備庫記錄當(dāng)前 scn 號:

      sqlplus / as sysdba
      SELECT CURRENT_SCN FROM V$DATABASE;
      CURRENT_SCN
      -----------
      2600487
      

      b.使用recover standby using service恢復(fù)

      采用rman的新功能,recover standby using service,通過RMAN連接到target備庫,然后用主庫的service執(zhí)行恢復(fù)備庫命令。

      語法:

      RECOVER DATABASE FROM SERVICE < PRIMARY DB SERVICE NAME > NOREDO USING COMPRESSED BACKUPSET;

      📢 注意: 確認主庫的TNS已配置,這里的< PRIMARY DB SERVICE NAME >即 TNSNAME。

      c.備庫啟動到nomount狀態(tài),恢復(fù)控制文件

      備庫啟動到nomount狀態(tài):

      sqlplus / as sysdba
      shutdown immediate
      startup nomount
      

      備庫通過from service恢復(fù)控制文件:

      rman target /
      restore standby controlfile from service orcl;
      

      備庫開啟到mount狀態(tài):

      sqlplus / as sysdba
      alter database mount;
      

      d.備庫恢復(fù),修復(fù)GAP

      檢查主備GAP期間是否添加數(shù)據(jù)文件:

      sqlplus / as sysdba
      select file# from v$datafile where creation_change# > =2600487;
      
      FILE#
      ----------
      13
      

      restore 新添加的數(shù)據(jù)文件:

      rman target /
      run
      {
      SET NEWNAME FOR DATABASE TO '/oradata/ORCL_STBY/%f_%U';
      RESTORE DATAFILE 13 FROM SERVICE orcl;
      }
      

      由于主備的數(shù)據(jù)文件目錄不一致,需要修改controlfile中數(shù)據(jù)文件位置:

      rman target /
      catalog start with '/oradata/ORCL_STBY';
      YES
      SWITCH DATABASE TO COPY;
      

      將備庫文件管理方式改為手動:

      sqlplus / as sysdba
      alter system set standby_file_management=MANUAL;
      

      重命名 tempfile && logfile:

      sqlplus / as sysdba
      ##logfile
      alter database clear logfile group 1;
      alter database clear logfile group 2;
      alter database clear logfile group 3;
      alter database clear logfile group 4;
      alter database clear logfile group 5;
      alter database clear logfile group 6;
      alter database clear logfile group 7;
      alter database rename file '/oradata/ORCL/redo03.log' to '/oradata/ORCL_STBY/redo03.log';
      alter database rename file '/oradata/ORCL/redo02.log' to '/oradata/ORCL_STBY/redo02.log';
      alter database rename file '/oradata/ORCL/redo01.log' to '/oradata/ORCL_STBY/redo01.log';
      alter database rename file '/oradata/ORCL/standby_redo04.log' to '/oradata/ORCL_STBY/standby_redo04.log';
      alter database rename file '/oradata/ORCL/standby_redo05.log' to '/oradata/ORCL_STBY/standby_redo05.log';
      alter database rename file '/oradata/ORCL/standby_redo06.log' to '/oradata/ORCL_STBY/standby_redo06.log';
      alter database rename file '/oradata/ORCL/standby_redo07.log' to '/oradata/ORCL_STBY/standby_redo07.log';
      ##tempfile
      alter database rename file '/oradata/ORCL/temp01.dbf' to '/oradata/ORCL_STBY/temp01.dbf';
      alter database rename file '/oradata/ORCL/pdbseed/temp012021-04-11_06-13-50-844-AM.dbf' to '/oradata/ORCL_STBY/pdbseed/temp012021-04-11_06-13-50-844-AM.dbf';
      alter database rename file '/oradata/ORCL/BFA6BEE45A1E3605E053AC01A8C0DD20/datafile/o1_mf_temp_j749f5fy_.dbf' to '/oradata/ORCL_STBY/BFA6BEE45A1E3605E053AC01A8C0DD20/datafile/o1_mf_temp_j749f5fy_.dbf';
      

      備庫重命名完后再改為自動:

      sqlplus / as sysdba
      alter system set standby_file_management=AUTO;
      

      恢復(fù)主備GAP:

      recover database from service orcl noredo using compressed backupset;
      

      📢 注意: 如果主備庫文件目錄不一致,則需要catalog切換控制文件中路徑,否則報錯:

      e.開啟備庫日志應(yīng)用,檢查同步

      • 檢查主備scn是否一致
      sqlplus / as sysdba
      col HXFNM for a100
      set line222
      select HXFIL File_num,substr(HXFNM,1,40) HXFNM,fhscn from x$kcvfh;
      
      • 主庫切幾次歸檔
      sqlplus / as sysdba
      ALTER SYSTEM ARCHIVE LOG CURRENT;
      ALTER SYSTEM SWITCH LOGFILE;
      
      • 開啟備庫應(yīng)用日志
      sqlplus / as sysdba
      alter database open;
      alter pluggable database all open;
      ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
      
      • 查看備庫同步是否正常
      sqlplus / as sysdba
      set line222
      col member for a60
      select t1.group#,t1.thread#,t1.bytes/1024/1024,t1.status,t2.member from gv$standby_log t1,gv$logfile t2 where t1.group#=t2.group#;
      
      • 主庫插入數(shù)據(jù)
      sqlplus test/test@pdb01
      insert into test values (999);
      commit;
      
      • 備庫查詢是否實時同步
      alter session set container=pdb01;
      select * from test.test;
      ID
      ----------
      1
      2
      999
      

      至此,GAP已修復(fù)完成,可以發(fā)現(xiàn),12C這個新特性,將一些步驟進行了省略和封裝,進一步減少了我們的操作步驟,但是內(nèi)部的原理仍然是一致的。

      五、18C新特性恢復(fù)

      18C 新特性是在 12C 的基礎(chǔ)上,將 RECOVER STANDBY DATABASE 命令與 FROM SERVICE 子句一起使用,以通過對主數(shù)據(jù)庫進行的更改來刷新物理備用數(shù)據(jù)庫。備庫可以直接在開啟狀態(tài)進行刷新。

      語法:

      RECOVER STANDBY DATABASE FROM SERVICE primary_db;

      首先,模擬備庫斷電,主庫切幾個最新的歸檔,然后手工刪掉,重新開啟DG同步。

      模擬GAP期間,有數(shù)據(jù)文件添加的情況:

      ##主庫添加數(shù)據(jù)文件
      alter tablespace TEST add datafile '/oradata/ORCL/test02.dbf' size 100M autoextend off;
      

      📢 注意: 當(dāng)前 DG 數(shù)據(jù)庫已存在 GAP,GAP 日志為:69—70。

      a、執(zhí)行RECOVER STANDBY DATABASE FROM SERVICE刷新備庫

      下面演示一下,如何使用一行命令在線修復(fù)DG GAP:

      備庫取消日志應(yīng)用:

      sqlplus / as sysdba
      ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
      

      備庫執(zhí)行修復(fù)命令,開始在線刷新備庫:

      rman target /
      RMAN> RECOVER STANDBY DATABASE FROM SERVICE orcl;
      
      Starting recover at 19-APR-21
      using target database control file instead of recovery catalog
      Oracle instance started
      
      Total System Global Area3355441944 bytes
      
      Fixed Size 9141016 bytes
      Variable Size671088640 bytes
      Database Buffers2667577344 bytes
      Redo Buffers   7634944 bytes
      
      contents of Memory Script:
      {
         restore standby controlfile from service  'orcl';
         alter database mount standby database;
      }
      executing Memory Script
      
      Starting restore at 19-APR-21
      allocated channel: ORA_DISK_1
      channel ORA_DISK_1: SID=502 device type=DISK
      
      channel ORA_DISK_1: starting datafile backup set restore
      channel ORA_DISK_1: using network backup set from service orcl
      channel ORA_DISK_1: restoring control file
      channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
      output file name=/oradata/ORCL_STBY/control01.ctl
      output file name=/oradata/ORCL_STBY/control02.ctl
      Finished restore at 19-APR-21
      
      released channel: ORA_DISK_1
      Statement processed
      Executing: alter system set standby_file_management=manual
      
      contents of Memory Script:
      {
      set newname for tempfile  1 to 
       "/oradata/ORCL_STBY/temp01.dbf";
      set newname for tempfile  2 to 
       "/oradata/ORCL_STBY/pdbseed/temp012021-04-11_06-13-50-844-AM.dbf";
      set newname for tempfile  3 to 
       "/oradata/ORCL_STBY/BFA6BEE45A1E3605E053AC01A8C0DD20/datafile/o1_mf_temp_j749f5fy_.dbf";
         switch tempfile all;
      set newname for datafile  1 to 
       "/oradata/ORCL_STBY/system01.dbf";
      set newname for datafile  3 to 
       "/oradata/ORCL_STBY/sysaux01.dbf";
      set newname for datafile  4 to 
       "/oradata/ORCL_STBY/undotbs01.dbf";
      set newname for datafile  5 to 
       "/oradata/ORCL_STBY/pdbseed/system01.dbf";
      set newname for datafile  6 to 
       "/oradata/ORCL_STBY/pdbseed/sysaux01.dbf";
      set newname for datafile  7 to 
       "/oradata/ORCL_STBY/users01.dbf";
      set newname for datafile  8 to 
       "/oradata/ORCL_STBY/pdbseed/undotbs01.dbf";
      set newname for datafile  9 to 
       "/oradata/ORCL_STBY/PDB01/o1_mf_system_j749f5d5_.dbf";
      set newname for datafile  10 to 
       "/oradata/ORCL_STBY/PDB01/o1_mf_sysaux_j749f5fw_.dbf";
      set newname for datafile  11 to 
       "/oradata/ORCL_STBY/PDB01/o1_mf_undotbs1_j749f5fx_.dbf";
      set newname for datafile  12 to 
       "/oradata/ORCL_STBY/test01.dbf";
      set newname for datafile  14 to 
       "/oradata/ORCL/test02.dbf";
         restore from service  'orcl' datafile
      14;
         catalog datafilecopy  "/oradata/ORCL_STBY/system01.dbf", 
       "/oradata/ORCL_STBY/sysaux01.dbf", 
       "/oradata/ORCL_STBY/undotbs01.dbf", 
       "/oradata/ORCL_STBY/pdbseed/system01.dbf", 
       "/oradata/ORCL_STBY/pdbseed/sysaux01.dbf", 
       "/oradata/ORCL_STBY/users01.dbf", 
       "/oradata/ORCL_STBY/pdbseed/undotbs01.dbf", 
       "/oradata/ORCL_STBY/PDB01/o1_mf_system_j749f5d5_.dbf", 
       "/oradata/ORCL_STBY/PDB01/o1_mf_sysaux_j749f5fw_.dbf", 
       "/oradata/ORCL_STBY/PDB01/o1_mf_undotbs1_j749f5fx_.dbf", 
       "/oradata/ORCL_STBY/test01.dbf", 
       "/oradata/ORCL/test02.dbf";
         switch datafile all;
      }
      executing Memory Script
      
      executing command: SET NEWNAME
      
      executing command: SET NEWNAME
      
      executing command: SET NEWNAME
      
      renamed tempfile 1 to /oradata/ORCL_STBY/temp01.dbf in control file
      renamed tempfile 2 to /oradata/ORCL_STBY/pdbseed/temp012021-04-11_06-13-50-844-AM.dbf in control file
      renamed tempfile 3 to /oradata/ORCL_STBY/BFA6BEE45A1E3605E053AC01A8C0DD20/datafile/o1_mf_temp_j749f5fy_.dbf in control file
      
      executing command: SET NEWNAME
      
      executing command: SET NEWNAME
      
      executing command: SET NEWNAME
      
      executing command: SET NEWNAME
      
      executing command: SET NEWNAME
      
      executing command: SET NEWNAME
      
      executing command: SET NEWNAME
      
      executing command: SET NEWNAME
      
      executing command: SET NEWNAME
      
      executing command: SET NEWNAME
      
      executing command: SET NEWNAME
      
      executing command: SET NEWNAME
      
      Starting restore at 19-APR-21
      allocated channel: ORA_DISK_1
      channel ORA_DISK_1: SID=504 device type=DISK
      
      channel ORA_DISK_1: starting datafile backup set restore
      channel ORA_DISK_1: using network backup set from service orcl
      channel ORA_DISK_1: specifying datafile(s) to restore from backup set
      channel ORA_DISK_1: restoring datafile 00014 to /oradata/ORCL/test02.dbf
      channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
      Finished restore at 19-APR-21
      
      cataloged datafile copy
      datafile copy file name=/oradata/ORCL_STBY/system01.dbf RECID=4 STAMP=1070263316
      cataloged datafile copy
      datafile copy file name=/oradata/ORCL_STBY/sysaux01.dbf RECID=5 STAMP=1070263317
      cataloged datafile copy
      datafile copy file name=/oradata/ORCL_STBY/undotbs01.dbf RECID=6 STAMP=1070263317
      cataloged datafile copy
      datafile copy file name=/oradata/ORCL_STBY/pdbseed/system01.dbf RECID=7 STAMP=1070263317
      cataloged datafile copy
      datafile copy file name=/oradata/ORCL_STBY/pdbseed/sysaux01.dbf RECID=8 STAMP=1070263318
      cataloged datafile copy
      datafile copy file name=/oradata/ORCL_STBY/users01.dbf RECID=9 STAMP=1070263318
      cataloged datafile copy
      datafile copy file name=/oradata/ORCL_STBY/pdbseed/undotbs01.dbf RECID=10 STAMP=1070263318
      cataloged datafile copy
      datafile copy file name=/oradata/ORCL_STBY/PDB01/o1_mf_system_j749f5d5_.dbf RECID=11 STAMP=1070263318
      cataloged datafile copy
      datafile copy file name=/oradata/ORCL_STBY/PDB01/o1_mf_sysaux_j749f5fw_.dbf RECID=12 STAMP=1070263318
      cataloged datafile copy
      datafile copy file name=/oradata/ORCL_STBY/PDB01/o1_mf_undotbs1_j749f5fx_.dbf RECID=13 STAMP=1070263318
      cataloged datafile copy
      datafile copy file name=/oradata/ORCL_STBY/test01.dbf RECID=14 STAMP=1070263318
      cataloged datafile copy
      datafile copy file name=/oradata/ORCL/test02.dbf RECID=15 STAMP=1070263318
      
      datafile 14 switched to datafile copy
      input datafile copy RECID=15 STAMP=1070263318 file name=/oradata/ORCL/test02.dbf
      datafile 1 switched to datafile copy
      input datafile copy RECID=4 STAMP=1070263316 file name=/oradata/ORCL_STBY/system01.dbf
      datafile 3 switched to datafile copy
      input datafile copy RECID=5 STAMP=1070263317 file name=/oradata/ORCL_STBY/sysaux01.dbf
      datafile 4 switched to datafile copy
      input datafile copy RECID=6 STAMP=1070263317 file name=/oradata/ORCL_STBY/undotbs01.dbf
      datafile 5 switched to datafile copy
      input datafile copy RECID=7 STAMP=1070263317 file name=/oradata/ORCL_STBY/pdbseed/system01.dbf
      datafile 6 switched to datafile copy
      input datafile copy RECID=8 STAMP=1070263318 file name=/oradata/ORCL_STBY/pdbseed/sysaux01.dbf
      datafile 7 switched to datafile copy
      input datafile copy RECID=9 STAMP=1070263318 file name=/oradata/ORCL_STBY/users01.dbf
      datafile 8 switched to datafile copy
      input datafile copy RECID=10 STAMP=1070263318 file name=/oradata/ORCL_STBY/pdbseed/undotbs01.dbf
      datafile 9 switched to datafile copy
      input datafile copy RECID=11 STAMP=1070263318 file name=/oradata/ORCL_STBY/PDB01/o1_mf_system_j749f5d5_.dbf
      datafile 10 switched to datafile copy
      input datafile copy RECID=12 STAMP=1070263318 file name=/oradata/ORCL_STBY/PDB01/o1_mf_sysaux_j749f5fw_.dbf
      datafile 11 switched to datafile copy
      input datafile copy RECID=13 STAMP=1070263318 file name=/oradata/ORCL_STBY/PDB01/o1_mf_undotbs1_j749f5fx_.dbf
      datafile 12 switched to datafile copy
      input datafile copy RECID=14 STAMP=1070263318 file name=/oradata/ORCL_STBY/test01.dbf
      Executing: alter database rename file '/oradata/ORCL/redo01.log' to '/oradata/ORCL_STBY/redo01.log'
      Executing: alter database rename file '/oradata/ORCL/redo02.log' to '/oradata/ORCL_STBY/redo02.log'
      Executing: alter database rename file '/oradata/ORCL/redo03.log' to '/oradata/ORCL_STBY/redo03.log'
      
      contents of Memory Script:
      {
        recover database from service  'orcl';
      }
      executing Memory Script
      
      Starting recover at 19-APR-21
      using channel ORA_DISK_1
      skipping datafile 5; already restored to SCN 2155383
      skipping datafile 6; already restored to SCN 2155383
      skipping datafile 8; already restored to SCN 2155383
      skipping datafile 14; already restored to SCN 2658548
      channel ORA_DISK_1: starting incremental datafile backup set restore
      channel ORA_DISK_1: using network backup set from service orcl
      destination for restore of datafile 00001: /oradata/ORCL_STBY/system01.dbf
      channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
      channel ORA_DISK_1: starting incremental datafile backup set restore
      channel ORA_DISK_1: using network backup set from service orcl
      destination for restore of datafile 00003: /oradata/ORCL_STBY/sysaux01.dbf
      channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
      channel ORA_DISK_1: starting incremental datafile backup set restore
      channel ORA_DISK_1: using network backup set from service orcl
      destination for restore of datafile 00004: /oradata/ORCL_STBY/undotbs01.dbf
      channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
      channel ORA_DISK_1: starting incremental datafile backup set restore
      channel ORA_DISK_1: using network backup set from service orcl
      destination for restore of datafile 00007: /oradata/ORCL_STBY/users01.dbf
      channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
      channel ORA_DISK_1: starting incremental datafile backup set restore
      channel ORA_DISK_1: using network backup set from service orcl
      destination for restore of datafile 00009: /oradata/ORCL_STBY/PDB01/o1_mf_system_j749f5d5_.dbf
      channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
      channel ORA_DISK_1: starting incremental datafile backup set restore
      channel ORA_DISK_1: using network backup set from service orcl
      destination for restore of datafile 00010: /oradata/ORCL_STBY/PDB01/o1_mf_sysaux_j749f5fw_.dbf
      channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
      channel ORA_DISK_1: starting incremental datafile backup set restore
      channel ORA_DISK_1: using network backup set from service orcl
      destination for restore of datafile 00011: /oradata/ORCL_STBY/PDB01/o1_mf_undotbs1_j749f5fx_.dbf
      channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
      channel ORA_DISK_1: starting incremental datafile backup set restore
      channel ORA_DISK_1: using network backup set from service orcl
      destination for restore of datafile 00012: /oradata/ORCL_STBY/test01.dbf
      channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
      
      starting media recovery
      
      media recovery complete, elapsed time: 00:00:00
      Finished recover at 19-APR-21
      Executing: alter system set standby_file_management=auto
      Finished recover at 19-APR-21
      

      方便大家查看,于是記錄恢復(fù)全過程,通過以上執(zhí)行過程,可以看到:

      • RECOVER STANDBY DATABASE命令重新啟動備用實例。
      • 從主數(shù)據(jù)庫刷新控制文件,并自動重命名數(shù)據(jù)文件,臨時文件和聯(lián)機日志。
      • 它可以還原添加到主數(shù)據(jù)庫中的新數(shù)據(jù)文件,并還原到當(dāng)前時間的備用數(shù)據(jù)庫。

      b.備庫修改standby log路徑

      發(fā)現(xiàn)刷新過后,備庫redo log路徑已修改,standby log路徑未修改,因此手動修改。

      查詢備庫的日志文件路徑:

      sqlplus / as sysdba
      SQL> select member from v$logfile;
      
      MEMBER
      --------------------------------------------------------------------------------
      /oradata/ORCL_STBY/redo03.log
      /oradata/ORCL_STBY/redo02.log
      /oradata/ORCL_STBY/redo01.log
      /oradata/ORCL/standby_redo04.log
      /oradata/ORCL/standby_redo05.log
      /oradata/ORCL/standby_redo06.log
      /oradata/ORCL/standby_redo07.log
      

      關(guān)閉備庫文件自動管理:

      sqlplus / as sysdba
      alter system set standby_file_management=MANUAL;
      

      清理standby log:

      sqlplus / as sysdba
      alter database clear logfile group 4;
      alter database clear logfile group 5;
      alter database clear logfile group 6;
      alter database clear logfile group 7;
      

      修改standby log路徑:

      sqlplus / as sysdba
      alter database rename file '/oradata/ORCL/standby_redo04.log' to '/oradata/ORCL_STBY/standby_redo04.log';
      alter database rename file '/oradata/ORCL/standby_redo05.log' to '/oradata/ORCL_STBY/standby_redo05.log';
      alter database rename file '/oradata/ORCL/standby_redo06.log' to '/oradata/ORCL_STBY/standby_redo06.log';
      alter database rename file '/oradata/ORCL/standby_redo07.log' to '/oradata/ORCL_STBY/standby_redo07.log';
      

      修改完后打開備庫文件自動管理:

      sqlplus / as sysdba
      alter system set standby_file_management=AUTO;
      

      c.主庫切日志,備庫開啟日志應(yīng)用

      檢查主備scn是否一致:

      sqlplus / as sysdba
      col HXFNM for a100
      set line222
      select HXFIL File_num,substr(HXFNM,1,40) HXFNM,fhscn from x$kcvfh;
      

      主庫切幾次歸檔:

      sqlplus / as sysdba
      ALTER SYSTEM ARCHIVE LOG CURRENT;
      ALTER SYSTEM SWITCH LOGFILE;
      

      開啟備庫應(yīng)用日志:

      sqlplus / as sysdba
      alter database open;
      alter pluggable database all open;
      ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
      

      查看備庫同步是否正常:

      sqlplus / as sysdba
      set line222
      col member for a60
      select t1.group#,t1.thread#,t1.bytes/1024/1024,t1.status,t2.member from gv$standby_log t1,gv$logfile t2 where t1.group#=t2.group#;
      

      主庫插入數(shù)據(jù):

      sqlplus test/test@pdb01
      insert into test values (999);
      commit;
      

      備庫查詢是否實時同步:

      sqlplus / as sysdba
      alter session set container=pdb01;
      select * from test.test;
      ID
      ----------
      1
      2
      999
      

      至此,18C的GAP也已修復(fù),可以看到Oracle隨著版本升級,越來越自動化的操作,意味著運維自動化的未來。

      參考文檔:

      • RESTORE/Recover from Service
      • Restoring and Recovering Files Over the Network(DG)
      • Restoring and Recovering Files Over the Network(RMAN)
      • Rolling Forward a Standby With One Command 18C

        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多