oracle異構rman遷移

目前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.

4.修改所有關於windows下目錄的參數如下:

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方式打開數據庫:
SQL> alter database open 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

由於是windows目錄格式linux 下oracle無法識別文件路徑,無法使用tempfile drop方式刪除文件;可以通過在線重建temp 表空間方式更改,這裏使用重建控制文件方式更改:

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 




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章