天天看点

rman restore controlfile

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

首先生成一个参数文件

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

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

查看生产的文件

.

[

oracle@hdp datafile]$ cat /tmp/.ora 
orcl.__db_cache_size=
orcl.__java_pool_size=
orcl.__large_pool_size=
orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=
orcl.__sga_target=
orcl.__shared_io_pool_size=
orcl.__shared_pool_size=
orcl.__streams_pool_size=
*.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=
*.db_create_file_dest='/u02/oradata/'
*.db_domain=''
*.db_file_multiblock_read_count=
*.db_name='orcl'
*.db_recovery_file_dest='/u02/backup'
*.db_recovery_file_dest_size=
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.memory_target=
*.open_cursors=
*.processes=
*.remote_login_passwordfile='EXCLUSIVE'
*.tracefile_identifier='dba_hdp_10053'
*.undo_tablespace='UNDOTBS1'
           

鸡汤:

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

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

[[email protected] tmp]$ cat 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'
``[[email protected] tmp]$ sqlplus / as sysdba

SQL*Plus: Release  Production on Mon Aug  :: 

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

Connected to an idle instance.

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

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


SQL> select status from v$instance
    /

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

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

Recovery Manager: Release  - Production on Mon Aug  :: 

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

connected to target database: ORCL (not mounted)

RMAN> restore controlfile from autobackup;

Starting restore at -AUG-
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/_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/_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 -AUG-

RMAN> exit


Recovery Manager complete.

自动生成了控制文件。

[[email protected] tmp]$ ls /u01/app/oracle/fast_recovery_area/orcl/control03.ctl
/u01/app/oracle/fast_recovery_area/orcl/control03.ctl
           

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

[[email protected] tmp]$ sqlplus / as sysdba

SQL*Plus: Release  Production on Mon Aug  :: 

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


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

SQL> alter database mount;

Database altered.


Disconnected from Oracle Database g Enterprise Edition Release  - bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[[email protected] tmp]$ rman target/

Recovery Manager: Release  - Production on Mon Aug  :: 

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

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

RMAN> recover database;

Starting recover at -AUG-
Starting implicit crosscheck backup at -AUG-
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID= device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID= device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID= device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID= device type=DISK
allocated channel: ORA_DISK_5
channel ORA_DISK_5: SID= device type=DISK
allocated channel: ORA_DISK_6
channel ORA_DISK_6: SID= device type=DISK
Crosschecked  objects
Finished implicit crosscheck backup at -AUG-

Starting implicit crosscheck copy at -AUG-
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 -AUG-

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

List of Cataloged Files
=======================
File Name: /u02/backup/ORCL/autobackup/_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  not processed because file is offline

starting media recovery

archived log for thread  with sequence  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= sequence=
media recovery complete, elapsed time: ::
Finished recover at -AUG-


RMAN> sql 'alter database open resetlogs'
> ;

sql statement: alter database open resetlogs

RMAN> 
           

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

shutdown => copy controlfile => 修改pfile => startup

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

the end

继续阅读