您的位置:首页 > 其它

利用rman进行异机还原(目录不同)

2013-09-22 14:26 363 查看
--注:备份操作省略,详见利用rman进行异机还原(目录相同)。下列操作均在目标服务器上进行。

--rman

[oracle@db02 ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Sep 22 08:19:14 2013

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

connected to target database: orcl (not mounted)

--设置dbid

RMAN> set dbid=1354163930

executing command: SET DBID

--还原控制文件

--在还原控制文件前,为了将控制文件与数据文件、日志文件放在同一文件目录,我对initsid.ora文件做了相应修改,此处省略...

RMAN> restore controlfile from '/u02/backup/ctl_20130922_0gokfho9_1_1.bak';

Starting restore at 22-SEP-13

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

output filename=/u03/oradata/orcl/control01.ctl

output filename=/u03/oradata/orcl/control02.ctl

output filename=/u03/oradata/orcl/control03.ctl

Finished restore at 22-SEP-13

--打开数据库到mount状态

RMAN> alter database mount;

database mounted

released channel: ORA_DISK_1

--执行下列run脚本(根据数据文件的不同作相应修改)

RMAN> run{

set newname for datafile '/u02/oradata/orcl/system01.dbf' to '/u03/oradata/orcl/system01.dbf';

set newname for datafile '/u02/oradata/orcl/undotbs01.dbf' to '/u03/oradata/orcl/undotbs01.dbf';

set newname for datafile '/u02/oradata/orcl/sysaux01.dbf' to '/u03/oradata/orcl/sysaux01.dbf.dbf';

set newname for datafile '/u02/oradata/orcl/users01.dbf' to '/u03/oradata/orcl/users01.dbf';

set newname for datafile '/u02/oradata/orcl/app01.dbf' to '/u03/oradata/orcl/app01.dbf';

restore database;

switch datafile all;

}

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 22-SEP-13

Starting implicit crosscheck backup at 22-SEP-13

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=155 devtype=DISK

Crosschecked 15 objects

Finished implicit crosscheck backup at 22-SEP-13

Starting implicit crosscheck copy at 22-SEP-13

using channel ORA_DISK_1

Finished implicit crosscheck copy at 22-SEP-13

searching for all files in the recovery area

cataloging files...

no files cataloged

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /u03/oradata/orcl/system01.dbf

restoring datafile 00002 to /u03/oradata/orcl/undotbs01.dbf

restoring datafile 00003 to /u03/oradata/orcl/sysaux01.dbf.dbf

restoring datafile 00004 to /u03/oradata/orcl/users01.dbf

restoring datafile 00005 to /u03/oradata/orcl/app01.dbf

channel ORA_DISK_1: reading from backup piece /u02/backup/dbf_20130922_0dokfhlq_1_1.bak

channel ORA_DISK_1: restored backup piece 1

piece handle=/u02/backup/dbf_20130922_0dokfhlq_1_1.bak tag=TAG20130922T071153

channel ORA_DISK_1: restore complete, elapsed time: 00:00:45

Finished restore at 22-SEP-13

datafile 1 switched to datafile copy

input datafile copy recid=6 stamp=826791673 filename=/u03/oradata/orcl/system01.dbf

datafile 2 switched to datafile copy

input datafile copy recid=7 stamp=826791673 filename=/u03/oradata/orcl/undotbs01.dbf

datafile 3 switched to datafile copy

input datafile copy recid=8 stamp=826791673 filename=/u03/oradata/orcl/sysaux01.dbf.dbf

datafile 4 switched to datafile copy

input datafile copy recid=9 stamp=826791673 filename=/u03/oradata/orcl/users01.dbf

datafile 5 switched to datafile copy

input datafile copy recid=10 stamp=826791673 filename=/u03/oradata/orcl/app01.dbf

--备注:set newname操作必须放置run{}中处理,不然会提示如下信息:

RMAN> set newname for datafile '/u02/oradata/orcl/system01.dbf' to '/u03/oradata/orcl/system01.dbf';

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03031: this option of set command needs to be used inside a run block

--执行完上述步骤后,再跳到sqlplus环境下执行如下脚本

SQL> alter database rename file '/u02/oradata/orcl/redo01.log' to '/u03/oradata/orcl/redo01.log';

Database altered.

SQL> alter database rename file '/u02/oradata/orcl/redo02.log' to '/u03/oradata/orcl/redo02.log';

Database altered.

SQL> alter database rename file '/u02/oradata/orcl/redo03.log' to '/u03/oradata/orcl/redo03.log';

Database altered.

--然后再回到rman执行

--恢复数据库

RMAN> recover database;

Starting recover at 22-SEP-13

using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archive log restore to default destination

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=37

channel ORA_DISK_1: reading from backup piece /u02/backup/arc_20130922_0fokfhnt_1_1.bak

channel ORA_DISK_1: restored backup piece 1

piece handle=/u02/backup/arc_20130922_0fokfhnt_1_1.bak tag=TAG20130922T071300

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

archive log filename=/u02/archivelog/1_37_826383194.dbf thread=1 sequence=37

unable to find archive log

archive log thread=1 sequence=38

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 09/22/2013 08:22:05

RMAN-06054: media recovery requesting unknown log: thread 1 seq 38 lowscn 378540

--打开数据库

RMAN> alter database open resetlogs;

database opened
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: