缺少初始化文件,数据库是无法启动的。如果通过RMAN备份了初始化参数,那么可以通过RMAN对初始化参数进行恢复。
这篇文章简单介绍CATALOG方式下初始化参数的恢复问题。
初始化参数的丢失和损坏,并不会造成太严重的问题,即使是最坏的情况,导致无法进行恢复,也是可以通过手工编辑一个新的PFILE文件,来启动实例的。
而且,在数据库的alert文件中包含了每次数据库启动使用的所有非默认值初始化参数,因此重新编写一个初始化参数并不困难。
不过,既然对SPFILE进行了备份,那么完全可以采用恢复的方式来还原SPFILE。
对于CATALOG方式,SPFILE的恢复相对简单很多。不过Oracle文档上对于SPFILE的恢复的描述有些小问题:SET DBID这个步骤是不能省略的,否则会报错。
$ rman target / catalog "rman/rman@testcen"
Recovery Manager: Release 9.2.0.4.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
connected to target database (not started)
connected to recovery catalog database
RMAN> startup force nomount;
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/opt/ora9/product/9.2/dbs/inittestdata.ora'
trying to start the Oracle instance without parameter files ...
Oracle instance started
Total System Global Area 97588504 bytes
Fixed Size 451864 bytes
Variable Size 46137344 bytes
Database Buffers 50331648 bytes
Redo Buffers 667648 bytes
RMAN> restore spfile;
Starting restore at 27-6月-07
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/27/2007 10:36:46
RMAN-12010: automatic channel allocation initialization failed
RMAN-06004: ORACLE error from recovery catalog database: RMAN-20001: target database not found in recovery catalog
正确的方式如下:
$ rman target / catalog "rman/rman@testcen"
Recovery Manager: Release 9.2.0.4.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
connected to target database: DUMMY (not mounted)
connected to recovery catalog database
RMAN> set dbid 2270762593;
executing command: SET DBID
RMAN> startup force nomount
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/opt/ora9/product/9.2/dbs/inittestdata.ora'
trying to start the Oracle instance without parameter files ...
Oracle instance started
Total System Global Area 97588504 bytes
Fixed Size 451864 bytes
Variable Size 46137344 bytes
Database Buffers 50331648 bytes
Redo Buffers 667648 bytes
RMAN> restore spfile;
Starting restore at 27-6月-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=9 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=10 devtype=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: sid=11 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: restoring SPFILE
output filename=/opt/ora9/product/9.2/dbs/spfiletestdata.ora
channel ORA_DISK_1: restored backup piece 1
piece handle=/data1/backup/testdata/c-2270762593-20070626-01 tag=null params=NULL
channel ORA_DISK_1: restore complete
Finished restore at 27-6月-07
RMAN> startup force
Oracle instance started
database mounted
database opened
Total System Global Area 1175525576 bytes
Fixed Size 452808 bytes
Variable Size 335544320 bytes
Database Buffers 838860800 bytes
Redo Buffers 667648 bytes
starting full resync of recovery catalog
full resync complete
SET DBID这个步骤是必须的。对于CATALOG模式,如果不知道数据库的ID,可以通过CATALOG用户登陆到CATALOG数据库中进行查询:
$ sqlplus rman/rman@testcen
SQL*Plus: Release 9.2.0.4.0 - Production on星期三6月27 15:36:30 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
Session altered.
SQL> select dbid from rc_database where name = 'TESTDATA';
DBID
----------
2270762593
恢复之后,重启数据库实例,使得SPFILE生效。