1. 程式人生 > >RMAN備份與恢復系列之redo日誌檔案恢復

RMAN備份與恢復系列之redo日誌檔案恢復

實驗環境

  • 作業系統 Redhat5.4 x86
  • 資料庫版本 oracle 11gR2 (11.2.0.1.0)
  • 實驗前已經做了RMAN全量備份包括controlfile、spfile

實驗模擬

1. INACTIVE日誌組部分member成員損壞或丟失

案例模擬

模擬group 4 中member disk4b.log檔案丟失:

SQL> select group#, sequence#,bytes/1024/1024M, members, status from v$log;

    GROUP#  SEQUENCE#          M    MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
     1
11 200 2 INACTIVE 2 12 200 2 INACTIVE 3 13 200 2 INACTIVE 4 14 200 2 INACTIVE 5 15 200 2 CURRENT SQL> select * from v$logfile; GROUP# STATUS TYPE MEMBER IS_ ---------- ------- ------- -------------------------------------------------- --- 1
ONLINE /u01/app/oracle/oradata/PROD/disk1/disk1a.log NO 1 ONLINE /u01/app/oracle/oradata/PROD/disk2/disk1b.log NO 2 ONLINE /u01/app/oracle/oradata/PROD/disk2/disk2a.log NO 2 ONLINE /u01/app/oracle/oradata/PROD/disk3/disk2b.log NO 3 ONLINE /u01/app/oracle/oradata/PROD/disk3/disk3a.log
NO 3 ONLINE /u01/app/oracle/oradata/PROD/disk4/disk3b.log NO 4 ONLINE /u01/app/oracle/oradata/PROD/disk4/disk4a.log NO 4 ONLINE /u01/app/oracle/oradata/PROD/disk5/disk4b.log NO 5 ONLINE /u01/app/oracle/oradata/PROD/disk5/disk5a.log NO 5 ONLINE /u01/app/oracle/oradata/PROD/disk1/disk5b.log NO 10 rows selected. SQL> !rm /u01/app/oracle/oradata/PROD/disk5/disk4b.log SQL> !ls -la /u01/app/oracle/oradata/PROD/disk5/disk4b.log ls: /u01/app/oracle/oradata/PROD/disk5/disk4b.log: No such file or directory

案例恢復

首先,在不重啟資料庫情況下,直接利用rman進行恢復:

[[email protected] dbs]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sun May 7 11:57:10 2017

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PROD (DBID=352761597)

RMAN> list failure;

using target database control file instead of recovery catalog
no failures found that match specification
RMAN> exit

Recovery Manager complete.

在不重啟資料庫的情況下,暫時檢查不到檔案丟失,
重啟資料庫以後,再次嘗試:

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area  836976640 bytes
Fixed Size          1339740 bytes
Variable Size         679480996 bytes
Database Buffers      150994944 bytes
Redo Buffers            5160960 bytes
Database mounted.
Database opened.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
--資料庫可以正常啟動,alert日誌中會有報錯提示資訊。

[[email protected] dbs]$ rman target / 

Recovery Manager: Release 11.2.0.1.0 - Production on Sun May 7 11:58:39 2017

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PROD (DBID=352761597)

RMAN> list failure;

using target database control file instead of recovery catalog
List of Database Failures
=========================

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
2176       HIGH     OPEN      07-MAY-17     Redo log file /u01/app/oracle/oradata/PROD/disk5/disk4b.log is missing

RMAN> advise failure;

List of Database Failures
=========================

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
2176       HIGH     OPEN      07-MAY-17     Redo log file /u01/app/oracle/oradata/PROD/disk5/disk4b.log is missing

analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=35 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions
========================
no manual actions available

Optional Manual Actions
=======================
1. If file /u01/app/oracle/oradata/PROD/disk5/disk4b.log was unintentionally renamed or moved, restore it

Automated Repair Options
========================
Option Repair Description
------ ------------------
1      Drop and re-create redo log group member /u01/app/oracle/oradata/PROD/disk5/disk4b.log  
  Strategy: The repair includes complete media recovery with no data loss
  Repair script: /u01/app/oracle/diag/rdbms/prod/PROD/hm/reco_3272967096.hm

RMAN> repair failure;

Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/prod/PROD/hm/reco_3272967096.hm

contents of repair script:
   # drop/recreate redo log group member
   sql "begin sys.dbms_ir.execsqlscript(filename => ''/u01/app/oracle/diag/rdbms/prod/PROD/hm/reco_162888668.hm'' ); end;";

Do you really want to execute the above repair (enter YES or NO)? YES
executing repair script

sql statement: begin sys.dbms_ir.execsqlscript(filename => ''/u01/app/oracle/diag/rdbms/prod/PROD/hm/reco_162888668.hm'' ); end;
repair failure complete

RMAN> exit


Recovery Manager complete.
[[email protected] dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun May 7 17:28:16 2017

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> !ls -la /u01/app/oracle/oradata/PROD/disk5/disk4b.log
-rw-r----- 1 oracle oinstall 209715712 May  7 17:28 /u01/app/oracle/oradata/PROD/disk5/disk4b.log

SQL> 

--通過重啟資料庫後,可以正常使用rman進行恢復。

RMAN中使用advise failure 生成的指令碼可以進行檢視具體的操作內容:

[[email protected] ~]$ cat /u01/app/oracle/diag/rdbms/prod/PROD/hm/reco_162888668.hm
begin
/*Drop the Log Member*/
execute immediate 'ALTER DATABASE DROP LOGFILE MEMBER ''/u01/app/oracle/oradata/PROD/disk5/disk4b.log''';
/*Add the Log Member (This will create a new file)*/
execute immediate 'ALTER DATABASE ADD LOGFILE MEMBER ''/u01/app/oracle/oradata/PROD/disk5/disk4b.log'' REUSE TO GROUP 4';
end;

因此,我們同樣可以按照指令碼內容手動進行恢復,inactive 日誌組中redo日誌檔案的恢復(這種方法不需要重啟資料庫):

SQL> alter database drop logfile member '/u01/app/oracle/oradata/PROD/disk5/disk4b.log';

Database altered.

SQL> alter database add logfile member '/u01/app/oracle/oradata/PROD/disk5/disk4b.log' reuse to group 4;

Database altered.

SQL> !ls -ls /u01/app/oracle/oradata/PROD/disk5/disk4b.log
205008 -rw-r----- 1 oracle oinstall 209715712 May  7 17:49 /u01/app/oracle/oradata/PROD/disk5/disk4b.log

這種情況下的資料庫可以正常啟動,資料恢復不會產生資料丟失。

2. INACTIVE日誌組全部的member成員都損壞或丟失

案例模擬

[[email protected] dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun May 7 18:15:24 2017

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from v$logfile;
    GROUP# STATUS  TYPE    MEMBER                           IS_
---------- ------- ------- ------------------------------------------------------------ ---
     1     ONLINE  /u01/app/oracle/oradata/PROD/disk1/disk1a.log        NO
     1 INVALID ONLINE  /u01/app/oracle/oradata/PROD/disk2/disk1b.log        NO
     2     ONLINE  /u01/app/oracle/oradata/PROD/disk2/disk2a.log        NO
     2     ONLINE  /u01/app/oracle/oradata/PROD/disk3/disk2b.log        NO
     3     ONLINE  /u01/app/oracle/oradata/PROD/disk3/disk3a.log        NO
     3     ONLINE  /u01/app/oracle/oradata/PROD/disk4/disk3b.log        NO
     4     ONLINE  /u01/app/oracle/oradata/PROD/disk5/disk4b.log        NO
     4     ONLINE  /u01/app/oracle/oradata/PROD/disk4/disk4a.log        NO
     5     ONLINE  /u01/app/oracle/oradata/PROD/disk5/disk5a.log        NO
     5     ONLINE  /u01/app/oracle/oradata/PROD/disk1/disk5b.log        NO

10 rows selected.
SQL> select group#, sequence#, members, archived, status from v$log;

    GROUP#  SEQUENCE#    MEMBERS ARC STATUS
---------- ---------- ---------- --- ----------------
     1     16          2 YES INACTIVE
     2     17          2 YES INACTIVE
     3     18          2 YES INACTIVE
     4     19          2 YES INACTIVE
     5     20          2 NO  CURRENT

SQL> !rm /u01/app/oracle/oradata/PROD/disk2/disk2a.log

SQL> !rm /u01/app/oracle/oradata/PROD/disk3/disk2b.log

SQL> exit            

案例恢復

[[email protected] dbs]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sun May 7 18:17:40 2017

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PROD (DBID=352761597)

RMAN> list failure;

using target database control file instead of recovery catalog
no failures found that match specification
--同樣需要重啟資料庫以後才能檢測到。
RMAN> exit


Recovery Manager complete.
[[email protected] dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun May 7 18:17:55 2017

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area  836976640 bytes
Fixed Size          1339740 bytes
Variable Size         683675300 bytes
Database Buffers      146800640 bytes
Redo Buffers            5160960 bytes
Database mounted.
ORA-03113: end-of-file on communication channel
Process ID: 27465
Session ID: 1 Serial number: 5


SQL> exit
--重啟資料庫以後發現數據庫無法啟動,報錯。

檢視alert日誌發現以下報錯資訊:

ALTER DATABASE OPEN
LGWR: STARTING ARCH PROCESSES
Sun May 07 18:18:12 2017
ARC0 started with pid=18, OS id=27467 
ARC0: Archival started
LGWR: STARTING ARCH PROCESSES COMPLETE
ARC0: STARTING ARCH PROCESSES
Sun May 07 18:18:13 2017
ARC1 started with pid=19, OS id=27469 
Errors in file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_lgwr_27413.trc:
ORA-00313: open failed for members of log group 1 of thread 1
Errors in file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_lgwr_27413.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/PROD/disk3/disk2b.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/PROD/disk2/disk2a.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_lgwr_27413.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/PROD/disk3/disk2b.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/PROD/disk2/disk2a.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_ora_27465.trc:
ORA-00313: open failed for members of log group 1 of thread 
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/PROD/disk2/disk2a.log'
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/PROD/disk3/disk2b.log'
USER (ospid: 27465): terminating the instance due to error 313
Sun May 07 18:18:13 2017
ARC2 started with pid=20, OS id=27471 
Instance terminated by USER, pid = 27465

再次登入RMAN進行恢復:

[[email protected] trace]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sun May 7 18:19:34 2017

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> startup mount;

Oracle instance started
database mounted

Total System Global Area     836976640 bytes

Fixed Size                     1339740 bytes
Variable Size                683675300 bytes
Database Buffers             146800640 bytes
Redo Buffers                   5160960 bytes

RMAN> list failure;

using target database control file instead of recovery catalog
List of Database Failures
=========================

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
2351       CRITICAL OPEN      07-MAY-17     Redo log group 2 is unavailable
2357       HIGH     OPEN      07-MAY-17     Redo log file /u01/app/oracle/oradata/PROD/disk3/disk2b.log is missing
2354       HIGH     OPEN      07-MAY-17     Redo log file /u01/app/oracle/oradata/PROD/disk2/disk2a.log is missing

RMAN> advise failure;

List of Database Failures
=========================

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
2351       CRITICAL OPEN      07-MAY-17     Redo log group 2 is unavailable
2357       HIGH     OPEN      07-MAY-17     Redo log file /u01/app/oracle/oradata/PROD/disk3/disk2b.log is missing
2354       HIGH     OPEN      07-MAY-17     Redo log file /u01/app/oracle/oradata/PROD/disk2/disk2a.log is missing

analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions
========================
no manual actions available

Optional Manual Actions
=======================
1. If file /u01/app/oracle/oradata/PROD/disk3/disk2b.log was unintentionally renamed or moved, restore it
2. If file /u01/app/oracle/oradata/PROD/disk2/disk2a.log was unintentionally renamed or moved, restore it

Automated Repair Options
========================
Option Repair Description
------ ------------------
1      Clear redo log group 2  
  Strategy: The repair includes complete media recovery with no data loss
  Repair script: /u01/app/oracle/diag/rdbms/prod/PROD/hm/reco_3329076409.hm
RMAN> repair failure;

Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/prod/PROD/hm/reco_3329076409.hm

contents of repair script:
   # clear redo log group
   sql "begin sys.dbms_ir.execsqlscript(filename => ''/u01/app/oracle/diag/rdbms/prod/PROD/hm/reco_4284357731.hm'' ); end;";

Do you really want to execute the above repair (enter YES or NO)? yes
executing repair script

sql statement: begin sys.dbms_ir.execsqlscript(filename => ''/u01/app/oracle/diag/rdbms/prod/PROD/hm/reco_4284357731.hm'' ); end;
repair failure complete

Do you want to open the database (enter YES or NO)? yes
database opened

RMAN> 

恢復完成後,登入資料庫進行檢查:

[[email protected] trace]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun May 7 18:30:29 2017

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> set line 180
SQL> col member for a60
SQL> select group#, sequence#, members, archived, status from v$log;

    GROUP#  SEQUENCE#    MEMBERS ARC STATUS
---------- ---------- ---------- --- ----------------
     1     16          2 YES INACTIVE
     2      0          2 YES UNUSED
     3     18          2 YES INACTIVE
     4     19          2 YES INACTIVE
     5     20          2 NO  CURRENT

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                           IS_
---------- ------- ------- ------------------------------------------------------------ ---
     1     ONLINE  /u01/app/oracle/oradata/PROD/disk1/disk1a.log        NO
     1 INVALID ONLINE  /u01/app/oracle/oradata/PROD/disk2/disk1b.log        NO
     2     ONLINE  /u01/app/oracle/oradata/PROD/disk2/disk2a.log        NO
     2     ONLINE  /u01/app/oracle/oradata/PROD/disk3/disk2b.log        NO
     3     ONLINE  /u01/app/oracle/oradata/PROD/disk3/disk3a.log        NO
     3     ONLINE  /u01/app/oracle/oradata/PROD/disk4/disk3b.log        NO
     4     ONLINE  /u01/app/oracle/oradata/PROD/disk5/disk4b.log        NO
     4     ONLINE  /u01/app/oracle/oradata/PROD/disk4/disk4a.log        NO
     5     ONLINE  /u01/app/oracle/oradata/PROD/disk5/disk5a.log        NO
     5     ONLINE  /u01/app/oracle/oradata/PROD/disk1/disk5b.log        NO

10 rows selected.

SQL> !ls -la /u01/app/oracle/oradata/PROD/disk2/disk2a.log
-rw-r----- 1 oracle oinstall 209715712 May  7 18:25 /u01/app/oracle/oradata/PROD/disk2/disk2a.log

SQL> !ls -la /u01/app/oracle/oradata/PROD/disk3/disk2b.log
-rw-r----- 1 oracle oinstall 209715712 May  7 18:25 /u01/app/oracle/oradata/PROD/disk3/disk2b.log

SQL> 
--之前手動刪除的兩個檔案已經恢復成功。

advise failure 生成的指令碼內容如下:

[[email protected] ~]$ cat /u01/app/oracle/diag/rdbms/prod/PROD/hm/reco_3329076409.hm
   # clear redo log group
   sql "begin sys.dbms_ir.execsqlscript(filename => ''/u01/app/oracle/diag/rdbms/prod/PROD/hm/reco_4284357731.hm'' ); end;";
[[email protected] ~]$ cat /u01/app/oracle/diag/rdbms/prod/PROD/hm/reco_4284357731.hm
begin
/*Clear the Log Group*/
execute immediate 'ALTER DATABASE CLEAR LOGFILE GROUP 2';
end;

因此,對於invactive redo group中所有member都丟失的情況下,我們還可以通過手動執行以下命令進行修復(由於inactive redo group中的日誌已經完成了checkpoint了,因此檔案中的內容已經不再需要,可以直接clear了):

ALTER DATABASE CLEAR LOGFILE GROUP 2

具體步驟如下:

--模擬檔案丟失或損壞:
SQL> select * from v$logfile;
SQL> /

    GROUP# STATUS  TYPE    MEMBER                           IS_
---------- ------- ------- ------------------------------------------------------------ ---
     1     ONLINE  /u01/app/oracle/oradata/PROD/disk1/disk1a.log        NO
     1 INVALID ONLINE  /u01/app/oracle/oradata/PROD/disk2/disk1b.log        NO
     2     ONLINE  /u01/app/oracle/oradata/PROD/disk2/disk2a.log        NO
     2     ONLINE  /u01/app/oracle/oradata/PROD/disk3/disk2b.log        NO
     3     ONLINE  /u01/app/oracle/oradata/PROD/disk3/disk3a.log        NO
     3     ONLINE  /u01/app/oracle/oradata/PROD/disk4/disk3b.log        NO
     4     ONLINE  /u01/app/oracle/oradata/PROD/disk5/disk4b.log        NO
     4     ONLINE  /u01/app/oracle/oradata/PROD/disk4/disk4a.log        NO
     5     ONLINE  /u01/app/oracle/oradata/PROD/disk5/disk5a.log        NO
     5     ONLINE  /u01/app/oracle/oradata/PROD/disk1/disk5b.log        NO

10 rows selected.

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
     1      1         16  209715200    512      2 YES INACTIVE            640479 07-MAY-17       640496 07-MAY-17
     2      1         21  209715200    512      2 NO  CURRENT             682181 07-MAY-17   2.8147E+14
     3      1         18  209715200    512      2 YES INACTIVE            640502 07-MAY-17       640514 07-MAY-17
     4      1         19  209715200    512      2 YES INACTIVE            640514 07-MAY-17       661074 07-MAY-17
     5      1         20  209715200    512      2 YES INACTIVE            661074 07-MAY-17       682181 07-MAY-17

SQL> 
SQL> !rm /u01/app/oracle/oradata/PROD/disk1/disk1a.log /u01/app/oracle/oradata/PROD/disk2/disk1b.log

SQL> startup force;
ORACLE instance started.

Total System Global Area  836976640 bytes
Fixed Size          1339740 bytes
Variable Size         683675300 bytes
Database Buffers      146800640 bytes
Redo Buffers            5160960 bytes
Database mounted.
ORA-03113: end-of-file on communication channel
Process ID: 29227
Session ID: 1 Serial number: 5


SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

--alert日誌報錯資訊如下:
ARC0: STARTING ARCH PROCESSES
Errors in file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_lgwr_29174.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/PROD/disk1/disk1a.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_lgwr_29174.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/PROD/disk1/disk1a.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Sun May 07 18:45:46 2017
ARC1 started with pid=19, OS id=29232 
Errors in file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_ora_29227.trc:
ORA-00313: open failed for members of log group 1 of thread 
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/PROD/disk1/disk1a.log'
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/PROD/disk2/disk1b.log'
USER (ospid: 29227): terminating the instance due to error 313
Instance terminated by USER, pid = 29227


--手動恢復方法:
[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun May 7 18:46:05 2017

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area  836976640 bytes
Fixed Size          1339740 bytes
Variable Size         683675300 bytes
Database Buffers      146800640 bytes
Redo Buffers            5160960 bytes
Database mounted.
SQL> alter database clear logfile group 1;

Database altered.

SQL> !ls -la /u01/app/oracle/oradata/PROD/disk2/disk1b.log
-rw-r----- 1 oracle oinstall 209715712 May  7 18:47 /u01/app/oracle/oradata/PROD/disk2/disk1b.log

SQL> !ls -la /u01/app/oracle/oradata/PROD/disk1/disk1a.log
-rw-r----- 1 oracle oinstall 209715712 May  7 18:47 /u01/app/oracle/oradata/PROD/disk1/disk1a.log

--執行完clear logfile命令以後檔案已經自動生成,下面可以直接將資料庫啟動到open狀態。

SQL> alter database open;

Database altered.

SQL> 

這種情況下,資料庫無法正常啟動,資料恢復不會造成資料丟失。

3. ACTIVE非CURRENT日誌組的部分member成員都損壞或丟失

案例模擬

SQL> select group#, sequence#, status, archived from v$log;

    GROUP#  SEQUENCE# STATUS           ARC
---------- ---------- ---------------- ---
     1     16 INACTIVE         YES
     2     17 ACTIVE           YES
     3     18 CURRENT          NO
     4     14 INACTIVE         YES
     5     15 INACTIVE         YES

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                           IS_
---------- ------- ------- ------------------------------------------------------------ ---
     1     ONLINE  /u01/app/oracle/oradata/PROD/disk1/disk1a.log        NO
     1     ONLINE  /u01/app/oracle/oradata/PROD/disk2/disk1b.log        NO
     2     ONLINE  /u01/app/oracle/oradata/PROD/disk2/disk2a.log        NO
     2     ONLINE  /u01/app/oracle/oradata/PROD/disk3/disk2b.log        NO
     3     ONLINE  /u01/app/oracle/oradata/PROD/disk4/disk3b.log        NO
     3     ONLINE  /u01/app/oracle/oradata/PROD/disk3/disk3a.log        NO
     4     ONLINE  /u01/app/oracle/oradata/PROD/disk4/disk4a.log        NO
     4     ONLINE  /u01/app/oracle/oradata/PROD/disk5/disk4b.log        NO
     5     ONLINE  /u01/app/oracle/oradata/PROD/disk5/disk5a.log        NO
     5     ONLINE  /u01/app/oracle/oradata/PROD/disk1/disk5b.log        NO

10 rows selected.

SQL> !rm /u01/app/oracle/oradata/PROD/disk3/disk2b.log
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area  836976640 bytes
Fixed Size          1339740 bytes
Variable Size         683675300 bytes
Database Buffers      146800640 bytes
Redo Buffers            5160960 bytes
Database mounted.
Database opened.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

--資料庫可以正常啟動,檢視alert日誌存在以下報錯資訊:

Sun May 07 20:57:11 2017
ARC0 started with pid=18, OS id=3495 
ARC0: Archival started
LGWR: STARTING ARCH PROCESSES COMPLETE
ARC0: STARTING ARCH PROCESSES
Errors in file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_lgwr_3433.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/PROD/disk3/disk2b.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_lgwr_3433.trc:
ORA-00321: log 2 of thread 1, cannot update log file header
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/PROD/disk3/disk2b.log'
Sun May 07 20:57:12 2017
ARC1 started with pid=19, OS id=3497 

案例恢復

[[email protected] ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sun May 7 20:57:49 2017

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PROD (DBID=352761597)

RMAN> list failure;

using target database control file instead of recovery catalog
List of Database Failures
=========================

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
2945       HIGH     OPEN      07-MAY-17     Redo log file /u01/app/oracle/oradata/PROD/disk3/disk2b.log is missing

RMAN> advise failure;

List of Database Failures
=========================

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
2945       HIGH     OPEN      07-MAY-17     Redo log file /u01/app/oracle/oradata/PROD/disk3/disk2b.log is missing

analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions
========================
no manual actions available

Optional Manual Actions
====