Oracle 12c|RMAN (FROM SERVICE)

在12cR1開始,RMAN提供了一個from service的子句讓備庫可以通過網絡來執行recover和restore命令。

在以下情況下可以使用這個新特性呢

  • 當備庫出現GAP,而主庫丟失歸檔需要做增量備份的時候

  • 當備庫丟失數據文件、控制文件以及表空間的需要restore的時候

1、檢查備庫 GAP 的情況

備庫狀態:

SQL> select * from v$archive_gap;

   THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#     CON_ID
---------- ------------- -------------- ----------
         1            21             21          1

SQL>  select current_scn from v$database;

CURRENT_SCN
-----------
    1808808

 

主庫scn :
 

SQL>  select current_scn from v$database;

CURRENT_SCN
-----------
    1810297

 

2、備庫通過from service子句進行增量恢復

將備庫啓動到nomount 狀態,重建控制文件

RMAN> restore standby controlfile from service orclst;

Starting restore at 09-SEP-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=36 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: using network backup set from service orclst
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/home/oracle/app/oracle/oradata/ORCL/controlfile/o1_mf_gq1mg6l6_.ctl
Finished restore at 09-SEP-19

 

3、爲防止在GAP期間有新增的數據文件 ,可以在主庫查詢斷檔之後主庫新增的數據文件(若沒有新增數據文件,這步可以跳過)

SQL> select FILE#,to_char(CREATION_TIME,'yyyy-mm-dd hh24:mi:ss') CREATION_TIME,STATUS,LAST_TIME,name from v$datafile where CREATION_CHANGE#>1808808;

no rows selected

SQL> /

     FILE# CREATION_TIME       STATUS  LAST_TIME
---------- ------------------- ------- ------------
NAME
------------------------------
         2 2019-09-09 02:50:53 ONLINE
/home/oracle/app/oracle/oradat
a/ORCLST/datafile/user01.dbf

 

通過from service恢復命令將新增的數據文件通過網絡在備庫恢復。

如果這裏不用 set newname 指定 文件的目錄及名稱,那麼文件名字和存放的目錄會和主庫一樣。

RMAN> run
2> {
3> SET NEWNAME FOR DATABASE TO '/home/oracle/app/oracle/oradata/ORCL/datafile/%f_%U';
4> RESTORE DATAFILE 2 FROM SERVICE orclst;
5> }

executing command: SET NEWNAME

Starting restore at 09-SEP-19
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: using network backup set from service orclst
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00002 to /home/oracle/app/oracle/oradata/ORCL/datafile/2_data_D-ORCL_TS-USERS_FNO-2
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 09-SEP-19

4、將數據文件註冊到控制文件:

RMAN>  catalog start with '/home/oracle/app/oracle/oradata/ORCL/datafile/';

searching for all files that match the pattern /home/oracle/app/oracle/oradata/ORCL/datafile/

List of Files Unknown to the Database
=====================================
File Name: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_system_gq1mcdxb_.dbf
File Name: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_gq1mdjd5_.dbf
File Name: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_gq1mf9p5_.dbf
File Name: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_users_gq1mfbw6_.dbf
File Name: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_temp_gq1mgfj6_.tmp

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...

 

5、至此,可以進行增量恢復了 ,在from service句式中還是可以使用常規備份時候使用的參數

  • SECTION SIZE (在傳輸時使用併發備份集傳輸)

  • USING COMPRESSED BACKUPSET (在傳輸時使用壓縮,減輕網絡壓力)

RMAN>  recover database from service orclst noredo SECTION SIZE 1G USING COMPRESSED BACKUPSET;

Starting recover at 09-SEP-19
using channel ORA_DISK_1
skipping datafile 2; already restored to SCN 1820457
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service orclst
destination for restore of datafile 00001: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_system_gq1mcdxb_.dbf
channel ORA_DISK_1: restoring section 1 of 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service orclst
destination for restore of datafile 00003: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_gq1mdjd5_.dbf
channel ORA_DISK_1: restoring section 1 of 1
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 compressed network backup set from service orclst
destination for restore of datafile 00004: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_gq1mf9p5_.dbf
channel ORA_DISK_1: restoring section 1 of 1
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 compressed network backup set from service orclst
destination for restore of datafile 00007: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_users_gq1mfbw6_.dbf
channel ORA_DISK_1: restoring section 1 of 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

Finished recover at 09-SEP-19

RMAN> 

至此,恢復過程已經完成

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章