我是靠谱客的博主 潇洒黑米,最近开发中收集的这篇文章主要介绍ORACLE RMAN异机恢复,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

测试平台信息:

Oracle:11gR2

操作系统:oel5.8

源库:CPP===>目标库MES.

注意事项:
 (1) 目标机器只需要安装oracle数据库软件即可。
(2)RMAN 异机恢复的时候,db_name必须相同。 如果说要想改成其他的实例名,可以在恢复成功后,用nid 命令修改。 实例名的信息会记录到控制文件里,所以如果在恢复的时候,如果实例名不一致,恢复的时候会报错。

(3)如果恢复的路径和源库不一致,就需要在restore时用set 命令指定新位置。 并且使用switch datafile all将信息更新的到控制文件。

       在做duplicate的时候,RMAN 会自动根据pfile中的log_file_name_convert和db_file_name_convert来进行set 的转换。 手工restore时,只能只只能使用set 命令。

(4) 用NID 修改DBID 和DBNAME.

. 源库准备工作:

(1). 查询DBID

SQL>  select name,dbid from v$database;
NAME DBID
--------- ----------
CPP  3679338048

(2).建立测试数据:

SQL> create table t as select * from dba_objects;
Table created.
SQL> insert into t select * from t;
86953 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from t;
  COUNT(*)
----------
    173906

(3).在源数据库上用rman备份数据库,包括数据库
a.备份数据文件和归档文件
[oracle@orcl1 ~]$ mkdir /u01/backup
[oracle@orcl1 rdbms]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Nov 23 00:36:05 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: CPP (DBID=3679338048)
RMAN> run {
allocate channel c1 device type disk;
backup incremental level 0
format '/u01/backup/db_full_%U.bkp'
tag 'db0'
database plus archivelog;
release channel c1;
}2> 3> 4> 5> 6> 7> 8> 
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=197 device type=DISK
Starting backup at 2014-11-23 00:36:14
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=6 RECID=1 STAMP=864347590
input archived log thread=1 sequence=7 RECID=2 STAMP=864347592
input archived log thread=1 sequence=8 RECID=3 STAMP=864347594
input archived log thread=1 sequence=9 RECID=4 STAMP=864347595
input archived log thread=1 sequence=10 RECID=5 STAMP=864347774
channel c1: starting piece 1 at 2014-11-23 00:36:15
channel c1: finished piece 1 at 2014-11-23 00:36:16
piece handle=/u01/backup/db_full_01po9pjv_1_1.bkp tag=DB0 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:02
Finished backup at 2014-11-23 00:36:17
Starting backup at 2014-11-23 00:36:17
channel c1: starting incremental level 0 datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/oracle/oradata/CPP/system01.dbf
input datafile file number=00002 name=/u01/oracle/oradata/CPP/sysaux01.dbf
input datafile file number=00005 name=/u01/oracle/oradata/CPP/example01.dbf
input datafile file number=00003 name=/u01/oracle/oradata/CPP/undotbs01.dbf
input datafile file number=00004 name=/u01/oracle/oradata/CPP/users01.dbf
channel c1: starting piece 1 at 2014-11-23 00:36:18
channel c1: finished piece 1 at 2014-11-23 00:37:43
piece handle=/u01/backup/db_full_02po9pk2_1_1.bkp tag=DB0 comment=NONE
channel c1: backup set complete, elapsed time: 00:01:25
channel c1: starting incremental level 0 datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel c1: starting piece 1 at 2014-11-23 00:37:45
channel c1: finished piece 1 at 2014-11-23 00:37:46
piece handle=/u01/backup/db_full_03po9pmo_1_1.bkp tag=DB0 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:02
Finished backup at 2014-11-23 00:37:47
Starting backup at 2014-11-23 00:37:47
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=11 RECID=6 STAMP=864347867
channel c1: starting piece 1 at 2014-11-23 00:37:48
channel c1: finished piece 1 at 2014-11-23 00:37:49
piece handle=/u01/backup/db_full_04po9pms_1_1.bkp tag=DB0 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 2014-11-23 00:37:50

released channel: c1

b.备份控制文件

RMAN> backup current controlfile format '/u01/backup/controlfile.bak';
Starting backup at 2014-11-23 00:41:32
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=197 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 2014-11-23 00:41:35
channel ORA_DISK_1: finished piece 1 at 2014-11-23 00:41:36
piece handle=/u01/backup/controlfile.bak tag=TAG20141123T004133 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2014-11-23 00:41:36
c.备份参数文件(可选)
RMAN> backup spfile format '/u01/backup/spfile.bak';
Starting backup at 2014-11-23 00:42:49
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2014-11-23 00:42:49
channel ORA_DISK_1: finished piece 1 at 2014-11-23 00:42:51
piece handle=/u01/backup/spfile.bak tag=TAG20141123T004249 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 2014-11-23 00:42:51
d.上传备份文件到目标库:
[oracle@orcl1 backup]$ ls
controlfile.bak           db_full_02po9pk2_1_1.bkp  db_full_04po9pms_1_1.bkp
db_full_01po9pjv_1_1.bkp  db_full_03po9pmo_1_1.bkp  spfile.bak
[oracle@orcl1 backup]$ scp * oracle@192.168.1.176:/u01/backup/
oracle@192.168.1.176's password: 
controlfile.bak                                                                        100% 9568KB   9.3MB/s   00:01    
db_full_01po9pjv_1_1.bkp                                                               100%   21MB  10.6MB/s   00:02    
db_full_02po9pk2_1_1.bkp                                                               100% 1187MB  10.4MB/s   01:54    
db_full_03po9pmo_1_1.bkp                                                               100% 9600KB   4.7MB/s   00:02    
db_full_04po9pms_1_1.bkp                                                               100%   25KB  24.5KB/s   00:00    
spfile.bak                                                                             100%   96KB  96.0KB/s   00:00    

6.拷贝密码文件到目标库:
[[oracle@orcl1 dbs]$ scp orapwCPP 192.168.1.176:/u01/oracle/product/11.2.0/db_1/dbs/
oracle@192.168.1.176's password: 
orapwCPP                                                                               100% 1536     1.5KB/s   00:00    
二.目标库准备工作:
a.创建相关目录:

b.启动目标库到nomount(用修改过的主库的参数文件):
[oracle@orcl2 admin]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Nov 23 00:58:20 2014
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area  546992128 bytes
Fixed Size    2255072 bytes
Variable Size  406849312 bytes
Database Buffers  130023424 bytes
Redo Buffers    7864320 bytes
c.恢复控制文件并mount数据库:
[oracle@orcl2 backup]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Nov 23 01:01:19 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: CPP (not mounted)
RMAN> restore controlfile from '/u01/backup/controlfile.bak';
Starting restore at 23-NOV-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output file name=/u01/oracle/oradata/MES/control01.ctl
output file name=/u01/oracle/fast_recovery_area/MES/control02.ctl---控制文件恢复的位置,是我们在pfile中的control_files参数控制的。
Finished restore at 23-NOV-14
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1

d.restore数据库(因为我们的路径不同,所以我们需要使用set 命令转换一下路径):
源库上查询:
SQL> set linesize 200
SQL> col file_name for a60
SQL> select file_id,file_name from dba_data_files;
   FILE_ID FILE_NAME
---------- ------------------------------------------------------------
4 /u01/oracle/oradata/CPP/users01.dbf
3 /u01/oracle/oradata/CPP/undotbs01.dbf
2 /u01/oracle/oradata/CPP/sysaux01.dbf
1 /u01/oracle/oradata/CPP/system01.dbf
5 /u01/oracle/oradata/CPP/example01.dbf
SQL> select file_id,file_name from dba_temp_files;
   FILE_ID FILE_NAME
---------- ------------------------------------------------------------
1 /u01/oracle/oradata/CPP/temp01.dbf (不会restore临时表空间,需要手动创建)

RMAN> run
{
set newname for datafile  1 to  "/u01/oracle/oradata/MES/system01.dbf";
set newname for datafile  2 to  "/u01/oracle/oradata/MES/sysaux01.dbf";
set newname for datafile  3 to  "/u01/oracle/oradata/MES/undotbs01.dbf";
set newname for datafile  4 to  "/u01/oracle/oradata/MES/users01.dbf";
set newname for datafile  5 to  "/u01/oracle/oradata/MES/example01.dbf";
restore database;
switch datafile all;
}2> 3> 4> 5> 6> 7> 8> 9> 10> 
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 23-NOV-14
Starting implicit crosscheck backup at 23-NOV-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK
Crosschecked 4 objects
Finished implicit crosscheck backup at 23-NOV-14
Starting implicit crosscheck copy at 23-NOV-14
using channel ORA_DISK_1
Finished implicit crosscheck copy at 23-NOV-14
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/oracle/oradata/MES/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/oracle/oradata/MES/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/oracle/oradata/MES/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/oracle/oradata/MES/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/oracle/oradata/MES/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/backup/db_full_02po9pk2_1_1.bkp
channel ORA_DISK_1: piece handle=/u01/backup/db_full_02po9pk2_1_1.bkp tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:26
Finished restore at 23-NOV-14
datafile 1 switched to datafile copy
input datafile copy RECID=7 STAMP=864349993 file name=/u01/oracle/oradata/MES/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=8 STAMP=864349993 file name=/u01/oracle/oradata/MES/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=9 STAMP=864349994 file name=/u01/oracle/oradata/MES/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=10 STAMP=864349994 file name=/u01/oracle/oradata/MES/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=11 STAMP=864349994 file name=/u01/oracle/oradata/MES/example01.dbf
(5)RECOVER DATABASE:
RMAN> recover database;
Starting recover at 23-NOV-14
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=11
channel ORA_DISK_1: reading from backup piece /u01/backup/db_full_04po9pms_1_1.bkp
channel ORA_DISK_1: piece handle=/u01/backup/db_full_04po9pms_1_1.bkp tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/oracle/fast_recovery_area/CPP/archivelog/2014_11_23/o1_mf_1_11_b71kdpto_.arc thread=1 sequence=11
channel default: deleting archived log(s)
archived log file name=/u01/oracle/fast_recovery_area/CPP/archivelog/2014_11_23/o1_mf_1_11_b71kdpto_.arc RECID=7 STAMP=864350358
unable to find archived log
archived log thread=1 sequence=12
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/23/2014 01:19:20
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 12 and starting SCN of 997676
RMAN> alter database open resetlogs;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 11/23/2014 01:22:00
ORA-00344: unable to re-create online log '/u01/oracle/oradata/CPP/redo01.log'
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 1
备注:测试的平台是11gR2的版本,在open resetlogs 之后,自动在原来默认的路径创建了temp 表空间和3redo 文件,先创建相应的路径,
SQL> select file_id,file_name from dba_temp_files;
   FILE_ID FILE_NAME
--------------------------------------------------------------------------------
 1/u01/oracle/oradata/CPP/temp01.dbf
SQL> select group#,member from v$logfile;
    GROUP# MEMBER
---------- ------------------------------------------------------------
3 /u01/oracle/oradata/CPP/redo03.log
2 /u01/oracle/oradata/CPP/redo02.log
1 /u01/oracle/oradata/CPP/redo01.log
alter database open resetlogs
*
ERROR at line 1:
ORA-00392: log 3 of thread 1 is being cleared, operation not allowed
ORA-00312: online log 3 thread 1: '/u01/oracle/oradata/CPP/redo03.log'
报错,执行以下sql解决:
SQL> select group#,bytes/1024/1024||'M',status from v$log;


    GROUP# BYTES/1024/1024||'M'     STATUS
---------- ----------------------------------------- ----------------
1 50M     CLEARING
3 50M     CLEARING_CURRENT
2 50M     CLEARING

SQL> alter database clear logfile group 1;

Database altered.

SQL> alter database clear logfile group 2;

Database altered.

SQL> alter database clear logfile group 3;

Database altered.

SQL>  alter database open resetlogs;

Database altered.

如果恢复目录和原来相同,就不用修改。

如果目录不同,我们就需要把这些文件移到我们现在的oradata目录。


SQL> select file_id,file_name from dba_temp_files;

   FILE_ID FILE_NAME
---------- ------------------------------------------------------------
1 /u01/oracle/oradata/CPP/temp01.dbf
SQL> select group#,member from v$logfile;
    GROUP# MEMBER
---------- ------------------------------------------------------------
 3 /u01/oracle/oradata/CPP/redo03.log
 2 /u01/oracle/oradata/CPP/redo02.log
 1 /u01/oracle/oradata/CPP/redo01.log
(1)处理 online redo log文件:
SQL> select group#,bytes/1024/1024||'M',status from v$log;
    GROUP# BYTES/1024/1024||'M'     STATUS
---------- ----------------------------------------- ----------------
1 50M     CURRENT
2 50M     UNUSED
3 50M     UNUSED
SQL> alter database drop logfile group 3;
Database altered.
SQL> alter database add logfile group 3 ('/u01/oracle/oradata/MES/redo03.log') size 50m;
Database altered.
SQL> alter database drop logfile group 2;
Database altered.
SQL> alter database add logfile group 2 ('/u01/oracle/oradata/MES/redo02.log') size 50m;
Database altered.
SQL> alter system switch logfile;(多次切换)
System altered.
SQL> alter database drop logfile group 1;
Database altered.
SQL> alter database add logfile group 1 ('/u01/oracle/oradata/MES/redo01.log') size 50m;
Database altered.
SQL> select group#,member from v$logfile;
  GROUP# MEMBER
---------- ------------------------------------------------------------
3 /u01/oracle/oradata/MES/redo03.log
2 /u01/oracle/oradata/MES/redo02.log
1 /u01/oracle/oradata/MES/redo01.log
处理临时表空间:
SQL> alter database tempfile '/u01/oracle/oradata/CPP/temp01.dbf' offline;
Database altered.
SQL> !mv /u01/oracle/oradata/CPP/temp01.dbf /u01/oracle/oradata/MES/temp01.dbf
SQL> alter database rename file '/u01/oracle/oradata/CPP/temp01.dbf' to '/u01/oracle/oradata/MES/temp01.dbf';
Database altered.
6.  NID 修改DBIDDBNAME
SQL> select name,dbid from v$database;
NAME DBID
--------- ----------
CPP  3679338048

注意事项:

a.在修改DBID期间仍然可能会遇到不可恢复的错误。所以修改之前备份数据库,特使是控制文件。因为nid 会修改控制文件中的信息。

b.需要将DB 启动到mount 状态才能修改。

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area  546992128 bytes
Fixed Size    2255072 bytes
Variable Size  406849312 bytes
Database Buffers  130023424 bytes
Redo Buffers    7864320 bytes
Database mounted.

1)只改DBID 不改db_name
[oracle@orcl2 backup]$ nid target=sys/123123
DBNEWID: Release 11.2.0.4.0 - Production on Sun Nov 23 01:59:25 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Connected to database CPP (DBID=3679338048)
Connected to server version 11.2.0
Control Files in database:
    /u01/oracle/oradata/MES/control01.ctl
    /u01/oracle/fast_recovery_area/MES/control02.ctl
Change database ID of database CPP? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 3679338048 to 3679316222
    Control File /u01/oracle/oradata/MES/control01.ctl - modified
    Control File /u01/oracle/fast_recovery_area/MES/control02.ctl - modified
    Datafile /u01/oracle/oradata/MES/system01.db - dbid changed
    Datafile /u01/oracle/oradata/MES/sysaux01.db - dbid changed
    Datafile /u01/oracle/oradata/MES/undotbs01.db - dbid changed
    Datafile /u01/oracle/oradata/MES/users01.db - dbid changed
    Datafile /u01/oracle/oradata/MES/example01.db - dbid changed
    Control File /u01/oracle/oradata/MES/control01.ctl - dbid changed
    Control File /u01/oracle/fast_recovery_area/MES/control02.ctl - dbid changed
    Instance shut down
Database ID for database CPP changed to 3679316222.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database ID.
DBNEWID - Completed succesfully.
[oracle@orcl2 backup]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Nov 23 02:00:36 2014
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup 
ORACLE instance started.
Total System Global Area  546992128 bytes
Fixed Size    2255072 bytes
Variable Size  406849312 bytes
Database Buffers  130023424 bytes
Redo Buffers    7864320 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
2)修改DBID DB_NAME
注意一点,修改DB_NAME 之前,要将spfile 创建成pfile,因为修改dbname之后,原来的参数文件就没用了。所以要保证最新的参数。 还有修改DB_NAME的值为最新值。 修改完之后,然后用这个新参数启动DB.
[oracle@orcl2 dbs]$ nid target=sys/123123 dbname=MES
DBNEWID: Release 11.2.0.4.0 - Production on Sun Nov 23 02:06:29 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Connected to database CPP (DBID=3679316222)
Connected to server version 11.2.0
Control Files in database:
    /u01/oracle/oradata/MES/control01.ctl
    /u01/oracle/fast_recovery_area/MES/control02.ctl
Change database ID and database name CPP to MES? (Y/[N]) => y
Proceeding with operation
Changing database ID from 3679316222 to 1947879013
Changing database name from CPP to MES
    Control File /u01/oracle/oradata/MES/control01.ctl - modified
    Control File /u01/oracle/fast_recovery_area/MES/control02.ctl - modified
    Datafile /u01/oracle/oradata/MES/system01.db - dbid changed, wrote new name
    Datafile /u01/oracle/oradata/MES/sysaux01.db - dbid changed, wrote new name
    Datafile /u01/oracle/oradata/MES/undotbs01.db - dbid changed, wrote new name
    Datafile /u01/oracle/oradata/MES/users01.db - dbid changed, wrote new name
    Datafile /u01/oracle/oradata/MES/example01.db - dbid changed, wrote new name
    Control File /u01/oracle/oradata/MES/control01.ctl - dbid changed, wrote new name
    Control File /u01/oracle/fast_recovery_area/MES/control02.ctl - dbid changed, wrote new name
    Instance shut down
Database name changed to MES.
Modify parameter file and generate a new password file before restarting.
Database ID for database MES changed to 1947879013.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.
[oracle@orcl2 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Nov 23 02:07:25 2014
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area  546992128 bytes
Fixed Size    2255072 bytes
Variable Size  406849312 bytes
Database Buffers  130023424 bytes
Redo Buffers    7864320 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
验证数据库DBNAME和DBID:
SQL> select name,dbid from v$database;
NAME DBID
--------- ----------
MES  1947879013
验证测试数据未丢失:
SQL> select count(*) from t;
COUNT(*)
----------
    173906
四.如果是在同一机器上克隆数据库,可以用重建控制文件的办法:
(1)完全备份源数据库:
(2)为目标库修改参数文件和密码文件:
MES.__db_cache_size=171966464
MES.__java_pool_size=4194304
MES.__large_pool_size=12582912
MES.__oracle_base='/u01/oracle'#ORACLE_BASE set from environment
MES.__pga_aggregate_target=226492416
MES.__sga_target=322961408
MES.__shared_io_pool_size=0
MES.__shared_pool_size=121634816
MES.__streams_pool_size=0
*.audit_file_dest='/u01/oracle/admin/MES/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/oracle/oradata/MES/control01.ctl','/u01/oracle/fast_recovery_area/MES/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='MES'
*.db_recovery_file_dest='/u01/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/u01/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=MESXDB)'
(3)拷贝所有日志文件和数据文件到目标库DATA目录下:
cp -p /u01/oracle/oradata/CPP/* /u01/oracle/oradata/MES/
(4)在源上生产重建控制文件的脚本
SQL> alter database backup controlfile to trace as '/home/oracle/control.txt';
Database altered.
cp -p /u01/oracle/oradata/CPP/* /u01/oracle/oradata/MES/
执行以下sql重建控制文件:
CREATE CONTROLFILE SET DATABASE "MES"RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/u01/oracle/oradata/MES/redo01.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 2 '/u01/oracle/oradata/MES/redo02.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 3 '/u01/oracle/oradata/MES/redo03.log'  SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '/u01/oracle/oradata/MES/system01.dbf',
  '/u01/oracle/oradata/MES/sysaux01.dbf',
  '/u01/oracle/oradata/MES/undotbs01.dbf',
  '/u01/oracle/oradata/MES/users01.dbf',
  '/u01/oracle/oradata/MES/example01.dbf'
CHARACTER SET AL32UTF8;
Control file created. 
5.恢复数据库
RMAN> restore database;
Starting restore at 2014-11-23 06:40:36
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/oracle/oradata/CPP/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/oracle/oradata/CPP/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/oracle/oradata/CPP/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/oracle/oradata/CPP/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/oracle/oradata/CPP/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/backup/db_full_07poae9n_1_1.bkp
channel ORA_DISK_1: piece handle=/u01/backup/db_full_07poae9n_1_1.bkp tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:15
Finished restore at 2014-11-23 06:41:53
RMAN> recover database;
Starting recover at 2014-11-23 06:42:33
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=9
channel ORA_DISK_1: reading from backup piece /u01/backup/db_full_09poaecq_1_1.bkp
channel ORA_DISK_1: piece handle=/u01/backup/db_full_09poaecq_1_1.bkp tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/oracle/fast_recovery_area/CPP/archivelog/2014_11_23/o1_mf_1_9_b724bw0t_.arc thread=1 sequence=9
channel default: deleting archived log(s)
archived log file name=/u01/oracle/fast_recovery_area/CPP/archivelog/2014_11_23/o1_mf_1_9_b724bw0t_.arc RECID=1 STAMP=864369756
unable to find archived log
archived log thread=1 sequence=10
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/23/2014 06:42:38
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 10 and starting SCN of 1003460
RMAN> alter database open resetlogs;
database opened
6.修改DBID(通过重建控制文件已经修改了DBNAME),所以只需要用NID修改dbid。

最后

以上就是潇洒黑米为你收集整理的ORACLE RMAN异机恢复的全部内容,希望文章能够帮你解决ORACLE RMAN异机恢复所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(52)

评论列表共有 0 条评论

立即
投稿
返回
顶部