合 Oracle SPFILE的恢复方式有哪几种?
SPFILE的恢复方式有哪几种?
答案:在数据库还没有关闭的情况下,可以使用如下的SQL从内存中恢复数据库的参数:
create spfile from memory;
create spfile='/home/oracle/spfileOCPLHR1.ora' from memory;
create pfile from memory;
create spfile from pfile;
除非必要,应该将以下划线开头的隐含参数删掉:
grep -v '^(_|#).' initlhrdb.ora > initlhrdb.ora2
如果数据库已经关闭,但是存在SPFILE的RMAN备份,那么可以使用如下的方式进行恢复:
l 如果知道数据库的DBID,那么可以按照如下步骤进行恢复:
startup nomount
set dbid 9815108;
restore spfile from autobackup;--已连接到了catalog恢复目录数据库
shutdown immediate
set dbid 9815108;
startup;
l 如果不知道数据库的DBID,那么可以按照如下步骤进行恢复:
① startup nomount;
② restore spfile from '备份文件';
③ shutdown immediate;
④ startup;
l 如果没有关于SPFILE的RMAN备份,那么可以从告警日志中获取数据库启动所需要的参数。
4.5.2 spfile 丢失
4.5.2.1 数据库没有挂掉
create spfile from memory;
create spfile='/home/oracle/spfileOCPLHR1.ora' from memory;
create pfile from memory;
create spfile from pfile;
除非必要,应该将以下划线开头的隐含参数删掉:
grep -v '^(_|#).' initlhrdb.ora > initlhrdb.ora2
4.5.2.2 数据库已经挂掉
一、 从rman的自动备份中找回
如果知道数据库的DBID,那么:
startup nomount
set dbid 9815108;
restore spfile from autobackup;--已连接到了catalog恢复目录数据库
shutdown immediate
set dbid 9815108;
startup;
如果不知道dbid可以这样做:
① startup nomount;
② restore spfile from '备份文件';
③ shutdown immediate;
④ startup;
restore spfile from autobackup; 可以成功的前提是连接到了catalog恢复目录数据库。
[oracle@OCPLHR dbs]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Sun Mar 25 20:29:42 2018
Copyright (c) 1982, 2011, 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/initOCPLHR1.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area 158662656 bytes
Fixed Size 2226456 bytes
Variable Size 130025192 bytes
Database Buffers 20971520 bytes
Redo Buffers 5439488 bytes
RMAN> restore spfile from autobackup;
Starting restore at 2018-03-25 20:30:08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=429 device type=DISK
RMAN-00571: ===========================================================