引數檔案控制檔案和資料檔案丟失的恢復

jane_pop發表於2014-08-26
在做這個實驗之前要保證資料庫存在有效的備份。

報錯資訊:
SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorcl.ora'
 
由提示資訊可知引數檔案丟失,資料庫無法nomount。
於是啟動rman在沒有引數檔案的情況下將資料庫開啟到nomount,然後使用autobackup恢復引數檔案,如果原來的磁碟已經損壞,
那麼我們就要將引數檔案恢復到其他目錄:
[oracle@localhost ~]$ rman target / nocatalog

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Aug 25 18:33:24 2014

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

connected to target database (not started)

RMAN> startup nomount

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorcl.ora'

starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started

Total System Global Area     159019008 bytes

Fixed Size                     1335192 bytes
Variable Size                 75497576 bytes
Database Buffers              79691776 bytes
Redo Buffers                   2494464 bytes

RMAN> set dbid=1383986269

executing command: SET DBID

RMAN> restore spfile to '/u01/app/spfile/spfileorcl.ora' from autobackup;

Starting restore at 25-AUG-14
using channel ORA_DISK_1

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140825
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140824
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140823
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140822
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140821
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140820
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140819
channel ORA_DISK_1: no AUTOBACKUP in 7 days found
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 08/25/2014 18:41:12
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece
出現這種錯誤是由於rman找不到自動備份,解決方法是指定路徑讓rman去找。

RMAN> restore spfile from '/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2014_08_25
2> /o1_mf_s_856548550_9zqqkqy0_.bkp';

Starting restore at 25-AUG-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2014_08_25/o1_mf_s_856548550_9zqqkqy0_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 25-AUG-14

啟動資料庫到mount:
SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00205: error in identifying control file, check alert log for more info

檢視警報日誌檔案:
ALTER DATABASE   MOUNT
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/flash_recovery_area/orcl/control02.ctl'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/orcl/control01.ctl'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory

控制檔案全部丟失,於是使用rman恢復控制檔案:
RMAN> restore controlfile to '/u01/app/controlfile/control01.ctl' from 
2> '/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2014_08_25
3> //o1_mf_s_856548550_9zqqkqy0_.bkp';

Starting restore at 25-AUG-14
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 25-AUG-14

修改引數control_files:
SQL> shutdown immediate;
ORA-01507: database not mounted

ORACLE instance shut down.
SQL> create pfile from spfile;

File created.

[oracle@localhost dbs]$ vi initorcl.ora

*.control_files='/u01/app/controlfile/control01.ctl'

SQL> create spfile from pfile;

File created.


開啟資料庫到mount:
SQL> startup mount;
ORACLE instance started.

Total System Global Area  849530880 bytes
Fixed Size                  1339824 bytes
Variable Size             553651792 bytes
Database Buffers          289406976 bytes
Redo Buffers                5132288 bytes
Database mounted.

開啟資料庫到open:
SQL> alter database open; 
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


檢視警報日誌檔案:
alter database open
Mon Aug 25 22:52:19 2014
Errors in file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_dbw0_11521.trc:
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/u01/app/oracle/oradata/orcl/hh01.dbf'
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/orcl/orcl/trace/orcl_ora_11611.trc:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
ORA-1589 signalled during: alter database open...

資料檔案hh01.dbf已經丟失,使用rman進行恢復:
[oracle@localhost app]$ rman target / nocatalog

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Aug 25 22:54:29 2014

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

connected to target database: ORCL (DBID=1383986269, not open)
using target database control file instead of recovery catalog

RMAN> restore database;

Starting restore at 25-AUG-14
using channel ORA_DISK_1

skipping datafile 1; already restored to file /u01/app/oracle/oradata/orcl/system01.dbf
skipping datafile 2; already restored to file /u01/app/oracle/oradata/orcl/sysaux01.dbf
skipping datafile 3; already restored to file /u01/app/oracle/oradata/orcl/undotbs01.dbf
skipping datafile 4; already restored to file /u01/app/oracle/oradata/orcl/users01.dbf
skipping datafile 5; already restored to file /u01/app/oracle/oradata/orcl/example01.dbf
skipping datafile 6; already restored to file /u01/app/datafile/test01.dbf
channel ORA_DISK_1: restoring datafile 00007
input datafile copy RECID=15 STAMP=856565947 file name=/u01/app/datafile/hh01.dbf
destination for restore of datafile 00007: /u01/app/oracle/oradata/orcl/hh01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00007
output file name=/u01/app/oracle/oradata/orcl/hh01.dbf RECID=0 STAMP=0
Finished restore at 25-AUG-14

RMAN> recover database;

Starting recover at 25-AUG-14
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 1 is already on disk as file /u01/app/archivelog/dest1/1_1_856310126.dbf
archived log for thread 1 with sequence 2 is already on disk as file /u01/app/archivelog/dest1/1_2_856310126.dbf
archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oracle/oradata/orcl/redo01.log
archived log for thread 1 with sequence 2 is already on disk as file /u01/app/oracle/oradata/orcl/redo02.log
archived log for thread 1 with sequence 3 is already on disk as file /u01/app/oracle/oradata/orcl/redo03.log
archived log file name=/u01/app/archivelog/dest1/1_1_856310126.dbf thread=1 sequence=1
archived log file name=/u01/app/archivelog/dest1/1_2_856310126.dbf thread=1 sequence=2
archived log file name=/u01/app/oracle/oradata/orcl/redo01.log thread=1 sequence=1
archived log file name=/u01/app/oracle/oradata/orcl/redo02.log thread=1 sequence=2
archived log file name=/u01/app/oracle/oradata/orcl/redo03.log thread=1 sequence=3
media recovery complete, elapsed time: 00:00:03
Finished recover at 25-AUG-14


再使用alter database open resetlogs;即可開啟資料庫。




 


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

相關文章