目前rman支持的异构恢复、还原和复制版本及对应的平台如下:
For Oracle Database 10g Release 2 and above releases:
Solaris x86-64 <--> Linux x86-64
HP-PA <--> HP-IA
Windows IA (64-bit) / Windows (64-bit Itanium) <--> Windows 64-bit for AMD / Windows (x86-64)
For Oracle Database 11g Release 1 and above releases (requires minimum 11.1 compatible setting):
Linux <--> Windows
For Oracle Database 11g Release 2 (11.2.0.2) and above releases:
Solaris SPARC (64-bit) <--> AIX (64-bit) - Note: this platform combination is currently not supported due to Bug 12702521
以下oracle 11.2.0.3的windows到linux为例:
1. 在windows上利用rman备份数据库
RMAN> run{
2> backup database format 'E:\bk_%d_%t_%s';
3> backup archivelog all format 'E:\al_%d_%t_%s';
4> backup current controlfile format 'E:\cntrl_%d_%t_%s';
5> }
2. 在linux 服务器上任意创建一个目录(如:/home/oracle/backup),将备份集ftp 到该目录下
3. 恢复spfile
#su – oracle
$export ORACLE_SID=orcl
$rman target / nocatalog
Recovery Manager: Release 11.2.0.3.0 - Production on Wed Aug 8 22:02:34 2012
Copyrigt (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> startup nomount
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/oracle/product/db_1/dbs/initorcl.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area 158662656 bytes
Fixed Size 2226456 bytes
Variable Size 92276456 bytes
Database Buffers 58720256 bytes
Redo Buffers 5439488 bytes
Rman>restore spfile from '/home/oracle/backup/BK_ORCL_790791123_3';
Starting restore at 2012-08-08 22:04:44
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
channel ORA_DISK_1: restoring spfile from AUTOBACKUP
/home/oracle/backup/BK_ORCL_790791123_3
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 2012-08-08 22:04:45
RMAN> shutdown immediate
Oracle instance shut down
$sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.3.0 Production on Wed Aug 8 22:08:13 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> create pfile from spfile;
File created.
orcl.__db_cache_size=138412032
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
#orcl.__oracle_base='E:\app\Administrator'#ORACLE_BASE set from environment
orcl.__oracle_base='/oracle/product'
orcl.__pga_aggregate_target=176160768
orcl.__sga_target=255852544
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=100663296
orcl.__streams_pool_size=0
#*.audit_file_dest='E:\app\Administrator\admin\orcl\adump'
*.audit_file_dest='/oracle/product/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
#*.control_files='E:\oradata\orcl\control01.ctl','E:\oradata\orcl\control02.ctl'
*.control_files='/oradata/orcl/control01.ctl','/oradata/orcl/control02.ctl'
*.db_domain=''
*.db_name='orcl'
#*.diagnostic_dest='E:\app\Administrator'
*.diagnostic_dest='/oracle/product'
*.nls_language='SIMPLIFIED CHINESE'
*.nls_territory='CHINA'
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1
$mkdir -p /oracle/product/admin/orcl/adump
$mkdir –p /oradata/orcl
5.恢复控制文件
SQL> create spfile from pfile;
File created.
$rman target / nocatalog
Recovery Manager: Release 11.2.0.3.0 - Production on Wed Aug 8 22:21:05 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> startup nomount;
Oracle instance started
Total System Global Area 242208768 bytes
Fixed Size 2227176 bytes
Variable Size 184550424 bytes
Database Buffers 50331648 bytes
Redo Buffers 5099520 bytes
RMAN> restore controlfile from '/home/oracle/backup/CNTRL_ORCL_790791465_5';
Starting restore at 2012-08-08 22:30:49
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output file name=/oradata/orcl/control01.ctl
output file name=/oradata/orcl/control02.ctl
Finished restore at 2012-08-08 22:30:53
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
6.将备份集信息导入控制文件:
RMAN> catalog start with '/home/oracle/backup/';
searching for all files that match the pattern /home/oracle/backup/
List of Files Unknown to the Database
=====================================
File Name: /home/oracle/backup/BK_ORCL_790791123_3
File Name: /home/oracle/backup/BK_ORCL_790791088_2
File Name: /home/oracle/backup/AL_ORCL_790791226_4
File Name: /home/oracle/backup/CTL_ORCL_790791465_5
Do you really want to catalog the above files (enter YES or NO)? Y
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /home/oracle/backup/BK_ORCL_790791123_3
File Name: /home/oracle/backup/BK_ORCL_790791088_2
File Name: /home/oracle/backup/AL_ORCL_790791226_4
File Name: /home/oracle/backup/CTL_ORCL_790791465_5
7.恢复数据文件:
RMAN> run{
2> set newname for datafile 1 to '/oradata/orcl/SYSTEM01.DBF';
3> set newname for datafile 2 to '/oradata/orcl/SYSAUX01.DBF';
4> set newname for datafile 3 to '/oradata/orcl/UNDOTBS01.DBF';
5> set newname for datafile 4 to '/oradata/orcl/USERS01.DBF';
6> restore database;
7> switch datafile all;
8> recover database;
9> }
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 2012-08-08 22:36:28
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 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 /oradata/orcl/SYSTEM01.DBF
channel ORA_DISK_1: restoring datafile 00002 to /oradata/orcl/SYSAUX01.DBF
channel ORA_DISK_1: restoring datafile 00003 to /oradata/orcl/UNDOTBS01.DBF
channel ORA_DISK_1: restoring datafile 00004 to /oradata/orcl/USERS01.DBF
channel ORA_DISK_1: reading from backup piece E:\BK_ORCL_790791088_2
channel ORA_DISK_1: errors found reading piece handle=E:\BK_ORCL_790791088_2
channel ORA_DISK_1: failover to piece handle=/home/oracle/backup/BK_ORCL_790791088_2
tag=TAG20120808T161128
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:17
Finished restore at 2012-08-08 22:38:46
datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=790814327 file name=/oradata/orcl/SYSTEM01.DBF
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=790814327 file name=/oradata/orcl/SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=790814327 file name=/oradata/orcl/UNDOTBS01.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=790814327 file name=/oradata/orcl/USERS01.DBF
Starting recover at 2012-08-08 22:38:48
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=14
channel ORA_DISK_1: reading from backup piece E:\AL_ORCL_790791226_4
channel ORA_DISK_1: errors found reading piece handle=E:\AL_ORCL_790791226_4
channel ORA_DISK_1: failover to piece handle=/home/oracle/backup/AL_ORCL_790791226_4
tag=TAG20120808T161346
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
archived log file name=/oracle/product/db_1/dbs/arch1_14_790789819.dbf thread=1 sequence=14
unable to find archived log
archived log thread=1 sequence=15
RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
===========================================================
RMAN-03002: failure of recover command at 08/08/2012 22:38:54
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 15
and starting SCN of 181422
以resetlogs方式打开数据库:
注意由于redo log和tempfile的路径都还是以windows目录方式记录在控制文件中,需要对其进行修改
QL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/oracle/product/db_1/dbs/E:ORADATAORCLREDO01.LOG
/oracle/product/db_1/dbs/E:ORADATAORCLREDO02.LOG
/oracle/product/db_1/dbs/E:ORADATAORCLREDO03.LOG
SQL> select file#,name from v$tempfile;
FILE# NAME
--------------------------------------------------------------------------------
1 E:\ORADATA\ORCL\TEMP01.DBF
SQL> alter database add logfile member '/oradata/orcl/redo01.log' to group 1;
Database altered.
SQL> alter database add logfile member '/oradata/orcl/redo02.log' to group 2;
Database altered.
SQL> alter database add logfile member '/oradata/orcl/redo03.log' to group 3;
Database altered.
SQL> select group#,member from v$logfile order by group#;
GROUP# MEMBER
------ --------------------------------------------------
1 /oracle/product/db_1/dbs/E:ORADATAORCLREDO01.LOG
1 /oradata/orcl/redo01.log
2 /oradata/orcl/redo02.log
2 /oracle/product/db_1/dbs/E:ORADATAORCLREDO02.LOG
3 /oradata/orcl/redo03.log
3 /oracle/product/db_1/dbs/E:ORADATAORCLREDO03.LOG
SQL> alter database drop logfile member
'/oracle/product/db_1/dbs/E:ORADATAORCLREDO01.LOG';
alter database drop logfile member '/oracle/product/db_1/dbs/E:ORADATAORCLREDO01.LOG'
*
ERROR at line 1:
ORA-00362: member is required to form a valid logfile in group 1
ORA-01517: log member: '/oracle/product/db_1/dbs/E:ORADATAORCLREDO01.LOG'
SQL> select group#,status,member from v$logfile order by group#;
GROUP# STATUS MEMBER
------ ------- --------------------------------------------------
1 /oracle/product/db_1/dbs/E:ORADATAORCLREDO01.LOG
1 INVALID /oradata/orcl/redo01.log
2 INVALID /oradata/orcl/redo02.log
2 /oracle/product/db_1/dbs/E:ORADATAORCLREDO02.LOG
3 INVALID /oradata/orcl/redo03.log
3 /oracle/product/db_1/dbs/E:ORADATAORCLREDO03.LOG
做下日志切换:
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> select group#,status,member from v$logfile order by group#;
GROUP# STATUS MEMBER
------ ------- --------------------------------------------------
1 /oracle/product/db_1/dbs/E:ORADATAORCLREDO01.LOG
1 /oradata/orcl/redo01.log
2 /oradata/orcl/redo02.log
2 /oracle/product/db_1/dbs/E:ORADATAORCLREDO02.LOG
3 /oradata/orcl/redo03.log
3 /oracle/product/db_1/dbs/E:ORADATAORCLREDO03.LOG
SQL> alter database drop logfile member
'/oracle/product/db_1/dbs/E:ORADATAORCLREDO01.LOG';
Database altered.
SQL> alter database drop logfile member
'/oracle/product/db_1/dbs/E:ORADATAORCLREDO02.LOG';
Database altered.
SQL> alter database drop logfile member
'/oracle/product/db_1/dbs/E:ORADATAORCLREDO03.LOG';
Database altered.
SQL> select group#,member from v$logfile;
GROUP# MEMBER
------ --------------------------------------------------
1 /oradata/orcl/redo01.log
2 /oradata/orcl/redo02.log
3 /oradata/orcl/redo03.log
SQL> alter database backup controlfile to trace as '/oracle/control.trc';
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 242208768 bytes
Fixed Size 2227176 bytes
Variable Size 184550424 bytes
Database Buffers 50331648 bytes
Redo Buffers 5099520 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS
ARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 5
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '/oradata/orcl/redo01.log' SIZE 50M BLOCKSIZE 512,
9 GROUP 2 '/oradata/orcl/redo02.log' SIZE 50M BLOCKSIZE 512,
10 GROUP 3 '/oradata/orcl/redo03.log' SIZE 50M BLOCKSIZE 512
11 -- STANDBY LOGFILE
12 DATAFILE
13 '/oradata/orcl/SYSTEM01.DBF',
14 '/oradata/orcl/SYSAUX01.DBF',
15 '/oradata/orcl/UNDOTBS01.DBF',
16 '/oradata/orcl/USERS01.DBF'
17 CHARACTER SET ZHS16GBK
18 ;
Control file created.
SQL> alter database open;
Database altered.
SQL> aLTER TABLESPACE TEMP ADD TEMPFILE '/oradata/orcl/temp01.dbf' reuse;
SQL> select file#,name from v$tempfile;
FILE# NAME
--------------------------------------------------------------------------------
1 /oradata/orcl/temp01.dbf