用rman备份spfile,删除spfile,然后使其恢复的过程

1)rman备份spfile参数文件
RMAN> backup spfile;
Starting backup at10-MAR-16
allocated channel:ORA_DISK_1
channel ORA_DISK_1:SID=37 device type=DISK
channel ORA_DISK_1:starting full datafile backup set
channel ORA_DISK_1:specifying datafile(s) in backup set
including currentSPFILE in backup set
channel ORA_DISK_1:starting piece 1 at 10-MAR-16
channel ORA_DISK_1:finished piece 1 at 10-MAR-16
piecehandle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/01r04pd4_1_1tag=TAG20160310T135235 comment=NONE
channel ORA_DISK_1:backup set complete, elapsed time: 00:00:02
Finished backup at10-MAR-16
2)删除spfile和pfile
[oracle@pridbs]$  rm /u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorclpri.ora
[oracle@pridbs]$  rm /u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorclpri.ora
3)启动数据库,报错,无法找到参数文件,
SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: couldnot open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorclpri.ora'
4)需要手工建立一个pfile参数文件,然后让数据库启动到nomount状态,rman才可以连接到数据库(pfile是文本模式,可以直接打开编辑;而spfile是二进制文件,无法直接编辑,所以这里编辑了pfile文件)
[oracle@pri dbs]$vi pfile_tmp.ora
db_name=orclpri
让数据库启动到nomount状态
SQL>  startup nomount pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/pfile_tmp.ora';
ORACLE instance started.
Total System GlobalArea  217157632 bytes
Fixed Size                  2251816 bytes
Variable Size             159384536 bytes
DatabaseBuffers           50331648 bytes
Redo Buffers                5189632 bytes
5)使用rman恢复刚才备份的spfile
RMAN> restore spfile from '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/01r04pd4_1_1';
Starting restore at10-MAR-16
using targetdatabase control file instead of recovery catalog
allocated channel:ORA_DISK_1
channel ORA_DISK_1:SID=20 device type=DISK
channel ORA_DISK_1:restoring spfile from AUTOBACKUP/u01/app/oracle/product/11.2.0/dbhome_1/dbs/01r04pd4_1_1
channel ORA_DISK_1:SPFILE restore from AUTOBACKUP complete
Finished restore at10-MAR-16
6)查看一下目录,出现了spfile文件,恢复成功
[oracle@pri dbs]$ll spfileorclpri.ora
-rw-r----- 1 oracleoinstall 3584 Mar 10 14:02 spfileorclpri.ora
7)重启数据库
SQL> shutdown immediate
ORA-01507: databasenot mounted
ORACLE instanceshut down.
SQL> startup
ORACLE instance started.
Total System GlobalArea  830930944 bytes
Fixed Size                  2257800 bytes
Variable Size             490736760 bytes
DatabaseBuffers          335544320 bytes
Redo Buffers                2392064 bytes
Database mounted.
Database opened.
8)现在是以恢复的spfile参数文件启动的
SQL> show parameter spfile;
NAME                 TYPE        VALUE
----------------------------------------------- ------------------------------
spfile               string      /u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorclpri.ora

猜你喜欢

转载自www.cnblogs.com/YJDBA/p/9724312.html