dg丟失歸檔,使用rman增量備份恢復

yingyifeng306發表於2021-02-20


透過rman 增量備份備份備庫還未同步的歸檔

透過查詢scn來確定增量備份的備份點

然後將增量備份的歸檔傳輸到備庫,

備庫註冊catalog備份片

 recover

   

 

檢視主備庫歸檔情況確定歸檔GAP

SELECT dest_id,THREAD#,NAME, sequence#,   archived,applied,a.NEXT_CHANGE#FROM   v$archived_log a WHERE  a.sequence# >= 40 AND      resetlogs_change# = (SELECT d.RESETLOGS_CHANGE# FROM v$database d)   ORDER  BY a.THREAD#,  a.sequence#,a.dest_id;

 

備庫上檢視丟失的歸檔:

SQL> SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM   V$ARCHIVE_GAP;

  THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#

----------   ------------- --------------

         1           140            155

 

備庫檢視丟失歸檔時的最小scn號:

SQL> select current_scn from v$database;

  CURRENT_SCN

-----------

1146993

SQL> select min(fhscn) from x$kcvfh;

 MIN(FHSCN)

----------------

1146994

 

 

在主庫以最小SCN號以RMAN建立增量備份:

[oracle@dg1 ~]$ rman target /

RMAN> backup    incremental from scn 1146993 database    format'/rman/bak_%U%t'tag'forstandby';

 

RMAN-00571:   ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS   ===============

RMAN-00571:   ===========================================================

RMAN-03009: failure of backup command on ORA_DISK_1 channel at   12/06/2016 07:26:47

ORA-19502: write error on file "/rman/bak_16rmp5tk_1_1929863604",   block number 1152 (block size=8192)

ORA-27072: File I/O error

Additional information: 4

Additional information: 1152

Additional information: 303104

報錯I/O錯誤

[oracle@dg1 ~]$ df -h

Filesystem              Size  Used Avail Use% Mounted on

/dev/sda3                16G   15G  9.4M 100% /

tmpfs                   932M  231M  702M    25% /dev/shm

/dev/sda1               2.0G   90M  1.8G     5% /boot

 

發現,空間不足導致的I/O錯誤 建立一塊磁碟掛載到/rman上 再執行命令

 

 

[oracle@dg1 ~]$ rman target /

  RMAN> backup  incremental   from scn 1146993 database    format'/rman/bak_%U%t';

 

複製備份到備庫

[oracle@dg1 rman]$ scp bak_18rmp811_1_1929865761  192.168.40.38:/oracle

[oracle@dg1 rman]$ scp bak_19rmp824_1_1929865796  192.168.40.38:/oracle

 

 

在主庫建立新的控制檔案

SQL> ALTER DATABASE CREATE standby controlfile AS   '/home/oracle/standby.ctl';

Database   altered.

 

 

複製到備庫:

[oracle@dg1 rman]$ scp /home/oracle/standby.ctl  192.168.40.38:/home/oracle/

 

 

備庫啟動到nomount狀態:

備庫上透過rman恢復控制檔案

RMAN> restore controlfile from'/oracle/standby.ctl';

 

Starting restore at 06-DEC-16

RMAN-00571:   ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS   ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 12/06/2016 14:52:50

ORA-03114: not connected to ORACLE

 

出現這個問題的原因是我的資料庫狀態是在另外一個視窗更改的,而rman未更新過資料庫狀態

當我退出rman並重新進入,再執行命令即可

RMAN> restore controlfile from '/oracle/standby.ctl';

 

 

備庫更改到mount狀態

SQL> alter database mount

Database   altered.

RMAN> list backup;

 

catalog 中註冊備份片

RMAN> CATALOG START WITH   '/oracle/bak_18rmp811_1_1929865761';

RMAN> CATALOG START WITH   '/oracle/bak_19rmp824_1_1929865796';

 

恢復資料庫

RMAN> recover database;

 

在備庫上重新啟動應用日誌:

 SQL>ALTER DATABASE recover managed standby DATABASE   disconnect FROM SESSION; 

 

主庫開啟,切換日誌:

SQL> startup

SQL> alter system switch logfile;

SQL> select max(sequence#) from v$archived_log;

 

備庫端alert日誌檢視:

[root@dg2 trace]# tail -f alert_credit.log

備庫在應用,恢復成功。

將主庫切換到begin backup 狀態,備庫切換到mount 狀態

將備庫的資料檔案刪除,

scp 主庫的資料檔案和歸檔到備庫

再將主庫切換到end backup狀態,備庫開啟,檢視狀態

 


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23732248/viewspace-2757966/,如需轉載,請註明出處,否則將追究法律責任。

相關文章