rman restore controlfile

本文介绍了通过RMAN工具新增数据库控制文件的过程及遇到的问题。包括生成参数文件、使用RMAN恢复控制文件、数据库恢复及开启数据库等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这篇文章主要是运用rman新增一个控制文件,并且在实验过程中发现了一些问题

首先生成一个参数文件

RMAN> restore spfile to  pfile '/tmp/001.ora' 
2> ;

Starting restore at 14-AUG-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=69 device type=DISK
(***ignore something ***)
channel ORA_DISK_1: reading from backup piece /u02/backup/ORCL/autobackup/2017_08_14/o1_mf_s_951965533_ds17yxoc_.bkp
channel ORA_DISK_1: piece handle=/u02/backup/ORCL/autobackup/2017_08_14/o1_mf_s_951965533_ds17yxoc_.bkp tag=TAG20170814T025213
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 14-AUG-17

查看生产的文件
.
[

oracle@hdp datafile]$ cat /tmp/001.ora 
orcl.__db_cache_size=687865856
orcl.__java_pool_size=16777216
orcl.__large_pool_size=33554432
orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=671088640
orcl.__sga_target=989855744
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=234881024
orcl.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/fast_recovery_area/orcl/control02.ctl'
*.db_block_size=8192
*.db_create_file_dest='/u02/oradata/'
*.db_domain=''
*.db_file_multiblock_read_count=8
*.db_name='orcl'
*.db_recovery_file_dest='/u02/backup'
*.db_recovery_file_dest_size=17179869184
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.memory_target=1653604352
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.tracefile_identifier='dba_hdp_10053'
*.undo_tablespace='UNDOTBS1'

鸡汤:
除了sqlplus 以外,我们又多了一个得到pfile的方法了。我就喜欢的ORACLE的开放性,虽然它是闭源的,但是大量的接口也足够让我们寻根问底了。

参数文件中多指定一个控制文件,这里是control03.ctl

[oracle@hdp tmp]$ cat 001.ora |grep control
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/fast_recovery_area/orcl/control02.ctl','/u01/app/oracle/fast_recovery_area/orcl/control03.ctl'
``[oracle@hdp tmp]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Aug 14 08:04:23 2017

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

Connected to an idle instance.

SQL> startup pfile='/tmp/001.ora'
ORACLE instance started.

Total System Global Area 1653518336 bytes
Fixed Size    2253784 bytes
Variable Size 1023413288 bytes
Database Buffers  620756992 bytes
Redo Buffers    7094272 bytes
ORA-00205: error in identifying control file, check alert log for more info


SQL> select status from v$instance
  2  /

STATUS
------------------------------------
STARTED

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@hdp tmp]$ rman target/

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Aug 14 08:05:01 2017

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

connected to target database: ORCL (not mounted)

RMAN> restore controlfile from autobackup;

Starting restore at 14-AUG-17
using channel ORA_DISK_1

recovery area destination: /u02/backup
database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: AUTOBACKUP /u02/backup/ORCL/autobackup/2017_08_14/o1_mf_s_951965533_ds17yxoc_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u02/backup/ORCL/autobackup/2017_08_14/o1_mf_s_951965533_ds17yxoc_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u01/app/oracle/oradata/orcl/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/orcl/control02.ctl
output file name=/u01/app/oracle/fast_recovery_area/orcl/control03.ctl
Finished restore at 14-AUG-17

RMAN> exit


Recovery Manager complete.

自动生成了控制文件。

[oracle@hdp tmp]$ ls /u01/app/oracle/fast_recovery_area/orcl/control03.ctl
/u01/app/oracle/fast_recovery_area/orcl/control03.ctl

当然由于我们控制文件回滚了,所以我们要recover了

[oracle@hdp tmp]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Aug 14 08:06:04 2017

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


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

SQL> alter database mount;

Database altered.


Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@hdp tmp]$ rman target/

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Aug 14 08:06:45 2017

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

connected to target database: ORCL (DBID=1477533441, not open)

RMAN> recover database;

Starting recover at 14-AUG-17
Starting implicit crosscheck backup at 14-AUG-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=129 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=192 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=6 device type=DISK
allocated channel: ORA_DISK_5
channel ORA_DISK_5: SID=67 device type=DISK
allocated channel: ORA_DISK_6
channel ORA_DISK_6: SID=130 device type=DISK
Crosschecked 12 objects
Finished implicit crosscheck backup at 14-AUG-17

Starting implicit crosscheck copy at 14-AUG-17
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
using channel ORA_DISK_6
Finished implicit crosscheck copy at 14-AUG-17

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u02/backup/ORCL/autobackup/2017_08_14/o1_mf_s_951965533_ds17yxoc_.bkp

using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
using channel ORA_DISK_6
datafile 4 not processed because file is offline

starting media recovery

archived log for thread 1 with sequence 36 is already on disk as file /u01/app/oracle/oradata/orcl/redo03.log
archived log file name=/u01/app/oracle/oradata/orcl/redo03.log thread=1 sequence=36
media recovery complete, elapsed time: 00:00:00
Finished recover at 14-AUG-17


RMAN> sql 'alter database open resetlogs'
2> ;

sql statement: alter database open resetlogs

RMAN> 

不过我感觉这可能不是正确增加controlfile的方法,resetlogs 丢没丢数据呢,这个锅咱不背 最稳妥的还是
shutdown => copy controlfile => 修改pfile => startup

不过这个命令在用rman做离线迁移的时候,倒是经常用。

the end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值