Oracle数据库的参数文件有两种一种是pfile(初始化参数文件),还有一种是spfile(服务器初始化参数文件);实际上spfile是pfile衍生过来的一新参数文件,应用9i以后的版本,在9i之前的版本都不支持,只支持pfile;而且pfile是不能通过oracle命令来进行备份的,只有spfile才支持备份。
通过RMAN的备份来实现参数文件的恢复,仅适用于9i以后
1、通过rman备份参数文件:
RMAN> backupspfile;
Starting backupat 05-JUL-12
using channelORA_DISK_1
channelORA_DISK_1: starting full datafile backupset
channelORA_DISK_1: specifying datafile(s) in backupset
including currentSPFILE in backupset
channelORA_DISK_1: starting piece 1 at 05-JUL-12
channelORA_DISK_1: finished piece 1 at 05-JUL-12
piecehandle=/DBBak/bak_WWL_07_05_03nfbi5c_1_1 tag=TAG20120705T175348 comment=NONE
channelORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backupat 05-JUL-12
Starting ControlFile and SPFILE Autobackup at 05-JUL-12
piecehandle=/DBSoft/product/10.2.0/db_1/dbs/c-5520179-20120705-01 comment=NONE
Finished ControlFile and SPFILE Autobackup at 05-JUL-12
RMAN>
2、备份完之后,我们可以看到如下备份信息:
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- ------------ ----------- ------------ ---------------
3 Full 80.00K DISK 00:00:01 05-JUL-12
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20120705T175348
Piece Name:/DBBak/bak_WWL_07_05_03nfbi5c_1_1
SPFILE Included: Modification time: 05-JUL-12
3、模拟参数文件丢失:
SQL> showparameter spfile;
NAME TYPE VALUE
----------------------------------------------- ------------------------------
spfile string /DBSoft/product/10.2.0/db_1/db
s/spfileWWL.ora
SQL>
删除参数文件:
[oracle@wwldb ~]$ rm /DBSoft/product/10.2.0/db_1/dbs/spfileWWL.ora
[oracle@wwldb ~]$ ls /DBSoft/product/10.2.0/db_1/dbs/spfileWWL.ora
ls: /DBSoft/product/10.2.0/db_1/dbs/spfileWWL.ora: No such file ordirectory
[oracle@wwldb dbs]$ ll
total 7240
drwxr-xr-x 2 oracle oinstall 4096 Jul 5 18:25 bak
-rw-rw---- 1 oracle oinstall 1544 May 16 16:44 hc_WWL.dat
-rw-rw---- 1 oracle oinstall 24 May 23 15:52 lkDUMMY
-rw-rw---- 1 oracle oinstall 24 May 16 16:47 lkWWL
-rw-r----- 1 oracle oinstall 1536 May 21 15:05 orapwWWL
drwxr-xr-x 2 oracle oinstall 4096 Jul 5 18:25 pfilebak
-rw-r----- 1 oracle oinstall 7389184 Jul 5 17:53 snapcf_WWL.f
[oracle@wwldb dbs]$
我们可以看到这里面pfile和spfile都没有了,那么数据库肯定是起不来的,这个时候需要数据库起来肯定需要恢复spfile或手工写一个pfile来供数据库的启动。