实验环境
- 操作系统 Redhat5.4 x86
- 数据库版本 oracle 11gR2 (11.2.0.1.0)
- 实验前已经做了RMAN全量备份包括controlfile、spfile
实验模拟
SPFILE文集损坏或丢失
案例模拟
[[email protected] dbs]$ sqlplus / as sysdba
SQL*Plus: Release Production on Mon May ::
Copyright (c) , , Oracle. All rights reserved.
Connected to:
Oracle Database g Enterprise Edition Release - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> show parameter spfile;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/
/dbhome_1/dbs/spfilePROD.ora
SQL> exit
Disconnected from Oracle Database g Enterprise Edition Release - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[[email protected] dbs]$ rm /u01/app/oracle/product//dbhome_1/dbs/spfilePROD.ora
[[email protected] dbs]$ sqlplus / as sysdba
SQL*Plus: Release Production on Mon May ::
Copyright (c) , , Oracle. All rights reserved.
Connected to:
Oracle Database g Enterprise Edition Release - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database g Enterprise Edition Release - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
案例恢复
[[email protected] dbs]$ rman target /
Recovery Manager: Release - Production on Mon May ::
Copyright (c) , , Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> startup;
startup failed: ORA-: failure in processing system parameters
LRM-: could not open parameter file '/u01/app/oracle/product//dbhome_1/dbs/initPROD.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
RMAN-: ===========================================================
RMAN-: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-: ===========================================================
RMAN-: failure of startup command at // ::
ORA-: error in identifying control file, check alert log for more info
--尝试从autobackup中恢复:
RMAN> restore spfile from autobackup;
Starting restore at -MAY-
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID= device type=DISK
channel ORA_DISK_1: looking for AUTOBACKUP on day:
channel ORA_DISK_1: looking for AUTOBACKUP on day:
channel ORA_DISK_1: looking for AUTOBACKUP on day:
channel ORA_DISK_1: looking for AUTOBACKUP on day:
channel ORA_DISK_1: looking for AUTOBACKUP on day:
channel ORA_DISK_1: looking for AUTOBACKUP on day:
channel ORA_DISK_1: looking for AUTOBACKUP on day:
channel ORA_DISK_1: no AUTOBACKUP in days found
RMAN-: ===========================================================
RMAN-: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-: ===========================================================
RMAN-: failure of restore command at // ::
RMAN-: no AUTOBACKUP found or specified handle is not a valid copy or piece
--从指定备份集中恢复:
RMAN> restore spfile from '/u01/app/oracle/flash_recovery_area/PROD/autobackup/_05_08/o1_mf_s_943401816_djykbthr_.bkp';
Starting restore at -MAY-
using channel ORA_DISK_1
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/flash_recovery_area/PROD/autobackup/_05_08/o1_mf_s_943401816_djykbthr_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at -MAY-
RMAN> exit
Recovery Manager complete.
[[email protected] dbs]$ sqlplus / as sysdba
SQL*Plus: Release Production on Mon May ::
Copyright (c) , , Oracle. All rights reserved.
Connected to:
Oracle Database g Enterprise Edition Release - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area bytes
Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes
Database mounted.
Database opened.
SQL>
如果以上方法还是无法恢复spfile,则可以通过查看alert日志文件,根据日志文件中的启动信息编辑一个pfile文件,然后由pfile文件创建spfile文件出来。