使用rman恢复参数文件

当我们的数据库实例的参数文件丢失了,怎么样把它找回呢?如下
在恢复的过程中,可能要用到dbid,所以下面 有两种方法可以查看dbid
方法一:查询v$database视图
SQL> select dbid from v$database;

      DBID
----------
1446008355
方法二:用rman连接上已将启动的数据库实例
[oracle@potato ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Feb 10 14:52:57 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL ( DBID=1446008355)

开始模拟丢失
[oracle@potato dbs]$ mv spfileorcl.ora spfileorcl.oraa
[oracle@potato dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Feb 10 14:54:31 2017

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> startup force;
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora'

使用rman连接进行恢复
[oracle@potato ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Feb 10 14:55:44 2017

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/db_1/dbs/initorcl.ora'

starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started

Total System Global Area     159019008 bytes

Fixed Size                     1343612 bytes
Variable Size                 75501444 bytes
Database Buffers              79691776 bytes
Redo Buffers                   2482176 bytes
若是我们不指定dbid用自动备份进行恢复,会报以下错误
RMAN> restore spfile from autobackup;

Starting restore at 10-FEB-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 02/10/2017 15:05:06
RMAN-06495: must explicitly specify DBID with SET DBID command

指定了dbid,再进行恢复
RMAN> SET DBID=1446008355;

executing command: SET DBID

RMAN> restore spfile from autobackup;

Starting restore at 10-FEB-17
using channel ORA_DISK_1

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20170210
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20170209
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20170208
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20170207
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20170206
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20170205
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20170204
channel ORA_DISK_1: no AUTOBACKUP in 7 days found
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 02/10/2017 15:05:59
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece

这里提示没有找到7日内的自动备份,这是因为我的库里面没有自动备份。
注: 若是你的库里存在spfile自动备份,在这一步就可以把库还原成功了。
所以我们只能通过直接指定备份片的方式恢复。
注: 使用直接指定路径恢复的方法是可以不指定dbid的
将spfile恢复到原来位置
RMAN> restore spfile to '/u01/app/oracle/product/11.2.0/db_1/dbs/spfileORCL.ora' from '/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2017_02_10/o1_mf_s_935591112_d9tq6bpj_.bkp';

Starting restore at 10-FEB-17
using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/fast_recovery_area/ORCL/autobackup/2017_02_10/o1_mf_s_935591112_d9tq6bpj_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 10-FEB-17

将数据库open
[oracle@potato dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Feb 10 14:45:39 2017

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> startup force;
ORACLE instance started.

Total System Global Area  828608512 bytes
Fixed Size                  1348104 bytes
Variable Size             545263096 bytes
Database Buffers          276824064 bytes
Redo Buffers                5173248 bytes
Database mounted.
Database opened.
到此数据库打开成功,意味着参数文件恢复成功了。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31386161/viewspace-2133372/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/31386161/viewspace-2133372/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值