日期:2014-05-16  浏览次数:20494 次

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

--注:备份操作省略,详见利用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 dataf