使用RMAN的Duplicate功能创建物理DataGuard


如果主端与备端目录不同,在两端的pfile文件中要添加,当然如果相同也可以添加:

*.log_file_name_convert='/u01/oradata/orcl/','/u02/oradata/orcl/'

*.db_file_name_convert='/u01/oradata/orcl/','/u02/oradata/orcl/'

  1. --在主端生成完全备份,包括归档日志与standby控制文件  
  2. [Oracle@source bak]rman target /   
  3.   
  4. Recovery Manager: Release 10.2.0.1.0 - Production on 星期四 4月 26 23:22:58 2012  
  5.   
  6. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  7.   
  8. connected to target database: ORCL (DBID=1309351439)  
  9.   
  10. RMAN> run{  
  11. backup FORMAT '/home/oracle/bak/orcl_%U_%T'  
  12. database  
  13. include current controlfile for standby  
  14. plus archivelog   
  15. ;  
  16. } 2> 3> 4> 5> 6> 7>   
  17.   
  18. --将完全备份copy 到备机  
  19. [oracle@source bak]$ scp * 192.168.1.103://home/oracle/bak  
  20.   
  21. --在备端以pfile启动到nomount状态,并创建spfile;  
  22. [oracle@target dbs]$ sqlplus / as sysdba  
  23.   
  24. SQL*Plus: Release 10.2.0.1.0 - Production on 星期五 4月 27 23:07:28 2012  
  25.   
  26. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  27.   
  28. Connected to an idle instance.  
  29.   
  30. SQL>  startup pfile=initorcl.ora nomount;  
  31. ORACLE instance started.  
  32.   
  33. Total System Global Area  276824064 bytes  
  34. Fixed Size          2020160 bytes  
  35. Variable Size          96472256 bytes  
  36. Database Buffers      176160768 bytes  
  37. Redo Buffers            2170880 bytes  
  38. SQL>  create spfile from pfile='initorcl.ora';  
  39.   
  40. File created.  
  41.   
  42. --在主端使用RMAN的Duplicate创建dg,如果数据文件与重做日志文件目录相同,要添加 nofilenamecheck ,否则不需要添加  
  43. [oracle@source bak]$ rmant an target /  
  44.   
  45. Recovery Manager: Release 10.2.0.1.0 - Production on  4 27 23:08:23 2012  
  46.   
  47. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  48.   
  49. connected to target database: ORCL (DBID=1309351439)  
  50.   
  51. RMAN> connect auxiliary sys/oracle@orcl_st  
  52.   
  53. connected to auxiliary database: ORCL (not mounted)  
  54.   
  55. RMAN>  run{  
  56. duplicate target database  
  57. for standby nofilenamecheck dorecover;  
  58. }2> 3> 4>   
  59.   
  60. Starting Duplicate Db at 2012-04-27 23:08:45  
  61. using target database control file instead of recovery catalog  
  62. allocated channel: ORA_AUX_DISK_1  
  63. channel ORA_AUX_DISK_1: sid=155 devtype=DISK  
  64.   
  65. contents of Memory Script:  
  66. {  
  67.    set until scn  611334;  
  68.    restore clone standby controlfile;  
  69.    sql clone 'alter database mount standby database';  
  70. }  
  71. executing Memory Script  
  72.   
  73. executing command: SET until clause  
  74.   
  75. Starting restore at 2012-04-27 23:08:45  
  76. using channel ORA_AUX_DISK_1  
  77.   
  78. channel ORA_AUX_DISK_1: starting datafile backupset restore  
  79. channel ORA_AUX_DISK_1: restoring control file  
  80. channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/bak/orcl_0cn9gs8i_1_1_20120427  
  81. channel ORA_AUX_DISK_1: restored backup piece 1  
  82. piece handle=/home/oracle/bak/orcl_0cn9gs8i_1_1_20120427 tag=TAG20120427T223632  
  83. channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01  
  84. output filename=/home/oracle/oradata/orcl/control01.ctl  
  85. output filename=/home/oracle/oradata/orcl/control02.ctl  
  86. output filename=/home/oracle/oradata/orcl/control03.ctl  
  87. Finished restore at 2012-04-27 23:08:47  
  88.   
  89. sql statement: alter database mount standby database  
  90. released channel: ORA_AUX_DISK_1  
  91.   
  92. contents of Memory Script:  
  93. {  
  94.    set until scn  611334;  
  95.    set newname for tempfile  1 to   
  96.  "/home/oracle/oradata/orcl/temp01.dbf";  
  97.    switch clone tempfile all;  
  98.    set newname for datafile  1 to   
  99.  "/home/oracle/oradata/orcl/system01.dbf";  
  100.    set newname for datafile  2 to   
  101.  "/home/oracle/oradata/orcl/undotbs01.dbf";  
  102.    set newname for datafile  3 to   
  103.  "/home/oracle/oradata/orcl/sysaux01.dbf";  
  104.    set newname for datafile  4 to   
  105.  "/home/oracle/oradata/orcl/users01.dbf";  
  106.    restore  
  107.    check readonly  
  108.    clone database  
  109.    ;  
  110. }  
  111. executing Memory Script  
  112.   
  113. executing command: SET until clause  
  114.   
  115. executing command: SET NEWNAME  
  116.   
  117. renamed temporary file 1 to /home/oracle/oradata/orcl/temp01.dbf in control file  
  118.   
  119. executing command: SET NEWNAME  
  120.   
  121. executing command: SET NEWNAME  
  122.   
  123. executing command: SET NEWNAME  
  124.   
  125. executing command: SET NEWNAME  
  126.   
  127. Starting restore at 2012-04-27 23:08:53  
  128. allocated channel: ORA_AUX_DISK_1  
  129. channel ORA_AUX_DISK_1: sid=155 devtype=DISK  
  130.   
  131. channel ORA_AUX_DISK_1: starting datafile backupset restore  
  132. channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set  
  133. restoring datafile 00001 to /home/oracle/oradata/orcl/system01.dbf  
  134. restoring datafile 00002 to /home/oracle/oradata/orcl/undotbs01.dbf  
  135. restoring datafile 00003 to /home/oracle/oradata/orcl/sysaux01.dbf  
  136. restoring datafile 00004 to /home/oracle/oradata/orcl/users01.dbf  
  137. channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/bak/orcl_0bn9gs3g_1_1_20120427  
  138. channel ORA_AUX_DISK_1: restored backup piece 1  
  139. piece handle=/home/oracle/bak/orcl_0bn9gs3g_1_1_20120427 tag=TAG20120427T223632  
  140. channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:15  
  141. Finished restore at 2012-04-27 23:10:10  
  142.   
  143. contents of Memory Script:  
  144. {  
  145.    switch clone datafile all;  
  146. }  
  147. executing Memory Script  
  148.   
  149. datafile 1 switched to datafile copy  
  150. input datafile copy recid=5 stamp=781744210 filename=/home/oracle/oradata/orcl/system01.dbf  
  151. datafile 2 switched to datafile copy  
  152. input datafile copy recid=6 stamp=781744210 filename=/home/oracle/oradata/orcl/undotbs01.dbf  
  153. datafile 3 switched to datafile copy  
  154. input datafile copy recid=7 stamp=781744210 filename=/home/oracle/oradata/orcl/sysaux01.dbf  
  155. datafile 4 switched to datafile copy  
  156. input datafile copy recid=8 stamp=781744210 filename=/home/oracle/oradata/orcl/users01.dbf  
  157.   
  158. contents of Memory Script:  
  159. {  
  160.    set until scn  611334;  
  161.    recover  
  162.    standby  
  163.    clone database  
  164.     delete archivelog  
  165.    ;  
  166. }  
  167. executing Memory Script  
  168.   
  169. executing command: SET until clause  
  170.   
  171. Starting recover at 2012-04-27 23:10:10  
  172. using channel ORA_AUX_DISK_1  
  173.   
  174. starting media recovery  
  175.   
  176. archive log thread 1 sequence 13 is already on disk as file /home/oracle/archive/1_13_781570707.dbf  
  177. archive log filename=/home/oracle/archive/1_13_781570707.dbf thread=1 sequence=13  
  178. media recovery complete, elapsed time: 00:00:02  
  179. Finished recover at 2012-04-27 23:10:14  
  180. Finished Duplicate Db at 2012-04-27 23:10:14  

完成后,备库启动到mount状态, 然后对DG进行验证。

更多Oracle相关信息见Oracle 专题页面 http://www.bkjia.com/topicnews.aspx?tid=12

相关内容