RMAN不停機搭建DG

哎呀我的天吶發表於2015-06-03

前面pfile引數等配置 參考如下:
http://blog.itpub.net/29990276/viewspace-1683772/

點選( 此處 )摺疊或開啟

  1. run{

  2. allocate channel c1 type disk ;

  3. allocate channel c2 type disk ;

  4. sql 'alter system archive log current' ;

  5. backup format '/backup/db_%U_%T' skip inaccessible filesperset 5 database ;

  6. sql 'alter system archive log current' ;

  7. backup format '/backuparch/arch_%U_%T' skip inaccessible filesperset 5 archivelog all delete input ;

  8. backup current controlfile for standby format = '/backup/control_%U' ;

  9. release channel c1 ;

  10. release channel c2 ;

  11. }

scp備份集到備庫相應的目錄

點選( 此處 )摺疊或開啟

  1. [ oracle@primary backuparch ] $ scp * 192 . 168 . 6 . 31 : / backuparch/

  2. oracle@192 . 168 . 6 . 31 's password:

  3. arch_05q8hd9e_1_1_20150603                                                                                                                                   100%   61MB  15.2MB/s   00:04

  4. arch_06q8hd9e_1_1_20150603                                                                                                                                   100% 9477KB   9.3MB/s   00:00

  5. arch_07q8hd9f_1_1_20150603                                                                                                                                   100%   66MB  16.5MB/s   00:04

  6. arch_08q8hd9g_1_1_20150603                                                                                                                                   100%   12MB  12.3MB/s   00:00

  7. [oracle@primary backuparch]$ cd /backup

  8. [ oracle@primary backup ] $ ll

  9. total 1154188

  10. - rw - r - - - - - 1 oracle oinstall   9797632 Jun  3 02 : 15 control_09q8hd9i_1_1

  11. - rw - r - - - - - 1 oracle oinstall 711983104 Jun  3 02 : 15 db_01q8hd8h_1_1_20150603

  12. - rw - r - - - - - 1 oracle oinstall 449028096 Jun  3 02 : 15 db_02q8hd8h_1_1_20150603

  13. - rw - r - - - - - 1 oracle oinstall   9797632 Jun  3 02 : 15 db_03q8hd9a_1_1_20150603

  14. - rw - r - - - - - 1 oracle oinstall     98304 Jun  3 02 : 15 db_04q8hd9a_1_1_20150603

  15. [ oracle@primary backup ] $ scp * 192 . 168 . 6 . 31 : / backup

  16. oracle@192 . 168 . 6 . 31's password:

  17. ... 

  18. ...

備庫duplicate登陸

點選( 此處 )摺疊或開啟

  1. [ oracle@standby ~ ] $ rman target sys/oracle@bj auxiliary sys/oracle@sh


  2. Recovery Manager : Release 11 . 2 . . 3 . 0 - Production on Tue Jun 2 11 : 18 : 17 2015


  3. Copyright ( c ) 1982 , 2011 , Oracle and / or its affiliates . All rights reserved .


  4. connected to target database : BEIJING ( DBID = 845781194 )

  5. connected to auxiliary database : BEIJING ( not mounted )



點選( 此處 )摺疊或開啟

  1. RMAN > duplicate target database for standby nofilenamecheck dorecover ;


  2. Starting Duplicate Db at 02 - JUN - 15

  3. using target database control file instead of recovery catalog

  4. allocated channel : ORA_AUX_DISK_1

  5. channel ORA_AUX_DISK_1 : SID = 19 device type = DISK


  6. contents of Memory Script :

  7. {

  8.    set until scn  1134882 ;

  9.    restore clone standby controlfile ;

  10. }

  11. executing Memory Script


  12. executing command : SET until clause


  13. Starting restore at 02 - JUN - 15

  14. using channel ORA_AUX_DISK_1


  15. channel ORA_AUX_DISK_1 : starting datafile backup set restore

  16. channel ORA_AUX_DISK_1 : restoring control file

  17. channel ORA_AUX_DISK_1 : reading from backup piece /backup/db_03q8hd9a_1_1_20150603

  18. channel ORA_AUX_DISK_1 : piece handle = / backup/db_03q8hd9a_1_1_20150603 tag = TAG20150603T021440

  19. channel ORA_AUX_DISK_1 : restored backup piece 1

  20. channel ORA_AUX_DISK_1 : restore complete , elapsed time : 00 : 00 : 02

  21. output file name = / u01/app/oracle/oradata/shanghai/control01 . ctl

  22. output file name = / u01/app/oracle/fast_recovery_area/shanghai/control02 . ctl

  23. Finished restore at 02 - JUN - 15


  24. contents of Memory Script :

  25. {

  26.    sql clone 'alter database mount standby database' ;

  27. }

  28. executing Memory Script


  29. sql statement : alter database mount standby database


  30. contents of Memory Script :

  31. {

  32.    set until scn  1134882 ;

  33.    set newname for tempfile  1 to

  34.   "/u01/app/oracle/oradata/shanghai/temp01.dbf" ;

  35.    switch clone tempfile all ;

  36.    set newname for datafile  1 to

  37.   "/u01/app/oracle/oradata/shanghai/system01.dbf" ;

  38.    set newname for datafile  2 to

  39.   "/u01/app/oracle/oradata/shanghai/sysaux01.dbf" ;

  40.    set newname for datafile  3 to

  41.   "/u01/app/oracle/oradata/shanghai/undotbs01.dbf" ;

  42.    set newname for datafile  4 to

  43.   "/u01/app/oracle/oradata/shanghai/users01.dbf" ;

  44.    set newname for datafile  5 to

  45.   "/u01/app/oracle/oradata/shanghai/example01.dbf" ;

  46.    restore

  47.    clone database

  48.     ;

  49. }

  50. executing Memory Script


  51. executing command : SET until clause


  52. executing command : SET NEWNAME


  53. renamed tempfile 1 to /u01/app/oracle/oradata/shanghai/temp01 . dbf in control file


  54. executing command : SET NEWNAME


  55. executing command : SET NEWNAME


  56. executing command : SET NEWNAME


  57. executing command : SET NEWNAME


  58. executing command : SET NEWNAME


  59. Starting restore at 02 - JUN - 15

  60. using channel ORA_AUX_DISK_1


  61. channel ORA_AUX_DISK_1 : starting datafile backup set restore

  62. channel ORA_AUX_DISK_1 : specifying datafile ( s ) to restore from backup set

  63. channel ORA_AUX_DISK_1 : restoring datafile 00001 to /u01/app/oracle/oradata/shanghai/system01 . dbf

  64. channel ORA_AUX_DISK_1 : restoring datafile 00005 to /u01/app/oracle/oradata/shanghai/example01 . dbf

  65. channel ORA_AUX_DISK_1 : reading from backup piece /backup/db_01q8hd8h_1_1_20150603

  66. channel ORA_AUX_DISK_1 : piece handle = / backup/db_01q8hd8h_1_1_20150603 tag = TAG20150603T021440

  67. channel ORA_AUX_DISK_1 : restored backup piece 1

  68. channel ORA_AUX_DISK_1 : restore complete , elapsed time : 00 : 00 : 15

  69. channel ORA_AUX_DISK_1 : starting datafile backup set restore

  70. channel ORA_AUX_DISK_1 : specifying datafile ( s ) to restore from backup set

  71. channel ORA_AUX_DISK_1 : restoring datafile 00002 to /u01/app/oracle/oradata/shanghai/sysaux01 . dbf

  72. channel ORA_AUX_DISK_1 : restoring datafile 00003 to /u01/app/oracle/oradata/shanghai/undotbs01 . dbf

  73. channel ORA_AUX_DISK_1 : restoring datafile 00004 to /u01/app/oracle/oradata/shanghai/users01 . dbf

  74. channel ORA_AUX_DISK_1 : reading from backup piece /backup/db_02q8hd8h_1_1_20150603

  75. channel ORA_AUX_DISK_1 : piece handle = / backup/db_02q8hd8h_1_1_20150603 tag = TAG20150603T021440

  76. channel ORA_AUX_DISK_1 : restored backup piece 1

  77. channel ORA_AUX_DISK_1 : restore complete , elapsed time : 00 : 00 : 15

  78. Finished restore at 02 - JUN - 15


  79. contents of Memory Script :

  80. {

  81.    switch clone datafile all ;

  82. }

  83. executing Memory Script


  84. datafile 1 switched to datafile copy

  85. input datafile copy RECID = 4 STAMP = 881320957 file name = / u01/app/oracle/oradata/shanghai/system01 . dbf

  86. datafile 2 switched to datafile copy

  87. input datafile copy RECID = 5 STAMP = 881320957 file name = / u01/app/oracle/oradata/shanghai/sysaux01 . dbf

  88. datafile 3 switched to datafile copy

  89. input datafile copy RECID = 6 STAMP = 881320957 file name = / u01/app/oracle/oradata/shanghai/undotbs01 . dbf

  90. datafile 4 switched to datafile copy

  91. input datafile copy RECID = 7 STAMP = 881320957 file name = / u01/app/oracle/oradata/shanghai/users01 . dbf

  92. datafile 5 switched to datafile copy

  93. input datafile copy RECID = 8 STAMP = 881320957 file name = / u01/app/oracle/oradata/shanghai/example01 . dbf


  94. contents of Memory Script :

  95. {

  96.    set until scn  1134882 ;

  97.    recover

  98.    standby

  99.    clone database

  100.     delete archivelog

  101.     ;

  102. }

  103. executing Memory Script


  104. executing command : SET until clause


  105. Starting recover at 02 - JUN - 15

  106. using channel ORA_AUX_DISK_1


  107. starting media recovery


  108. channel ORA_AUX_DISK_1 : starting archived log restore to default destination

  109. channel ORA_AUX_DISK_1 : restoring archived log

  110. archived log thread = 1 sequence = 14

  111. channel ORA_AUX_DISK_1 : restoring archived log

  112. archived log thread = 1 sequence = 15

  113. channel ORA_AUX_DISK_1 : reading from backup piece /backuparch/arch_08q8hd9g_1_1_20150603

  114. channel ORA_AUX_DISK_1 : piece handle = / backuparch/arch_08q8hd9g_1_1_20150603 tag = TAG20150603T021509

  115. channel ORA_AUX_DISK_1 : restored backup piece 1

  116. channel ORA_AUX_DISK_1 : restore complete , elapsed time : 00 : 00 : 01

  117. archived log file name = / arch/1_14_881314188 . dbf thread = 1 sequence = 14

  118. channel clone_default : deleting archived log ( s )

  119. archived log file name = / arch/1_14_881314188 . dbf RECID = 1 STAMP = 881320959

  120. archived log file name = / arch/1_15_881314188 . dbf thread = 1 sequence = 15

  121. channel clone_default : deleting archived log ( s )

  122. archived log file name = / arch/1_15_881314188 . dbf RECID = 2 STAMP = 881320959

  123. media recovery complete , elapsed time : 00 : 00 : 00

  124. Finished recover at 02 - JUN - 15

  125. Finished Duplicate Db at 02 - JUN - 15

中間有  alter database mount standby database;過程,一條命令搞定所有,但是不會做路徑的轉換,這時我們在pfile新增covert。

執行之後,資料庫是mount狀態,這時候我們就可以開啟備庫了。

點選( 此處 )摺疊或開啟

  1. SQL > alter database open ;


  2. Database altered .


  3. SQL > select open_mode from v$database ;


  4. OPEN_MODE

  5. - - - - - - - - - - - - - - - - - - - -

  6. READ ONLY

新增standby redo log和online redo log

應用

點選( 此處 )摺疊或開啟

  1. SQL > alter database recover managed standby database disconnect from session ;


  2. Database altered .




來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29990276/viewspace-1684408/,如需轉載,請註明出處,否則將追究法律責任。

相關文章