手机版
你好,游客 登录 注册
背景:
阅读新闻

Oracle 11gR2 搭建活动的物理DG/DataGuard (READ ONLY模式)

[日期:2012-09-09] 来源:Linux社区  作者:luoping [字体:大 中 小]

回到主备上面。

在前面我们修改了两个参数(db/log_file_name_convertt)到spfile文件中,还没有重启数据库,这里我们重启一下主数据库

3.1

  1. [Oracle@11g admin]$ sqlplus / as sysdba 
  2.  
  3. SQL*Plus: Release 11.2.0.2.0 Production on Fri Sep 7 05:50:13 2012 
  4.  
  5. Copyright (c) 1982, 2010, Oracle.  All rights reserved. 
  6.  
  7.  
  8. Connected to: 
  9. Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production 
  10. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  11.  
  12. SQL> shutdown immediate; 
  13. Database closed. 
  14. Database dismounted. 
  15. ORACLE instance shut down. 
  16. SQL> startup 
  17. ORACLE instance started. 
  18.  
  19. Total System Global Area  313159680 bytes 
  20. Fixed Size                  2226072 bytes 
  21. Variable Size             247466088 bytes 
  22. Database Buffers           58720256 bytes 
  23. Redo Buffers                4747264 bytes 
  24. Database mounted. 
  25. Database opened. 
  26. SQL> exit 
  27. Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production 
  28. With the Partitioning, OLAP, Data Mining and Real Application Testing options 

3.2 duplicate开始

  1. [oracle@11g admin]$ rman target sys/oracle@htz auxiliary sys/oracle@htzb 
  2.  
  3. Recovery Manager: Release 11.2.0.2.0 - Production on Fri Sep 7 05:50:46 2012 
  4.  
  5. Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved. 
  6.  
  7. connected to target database: HTZ (DBID=1848107928) 
  8. connected to auxiliary database: HTZ (not mounted) 
  9.  
  10. RMAN> run { 
  11. 2> allocate channel prmy1 type disk; 
  12. 3> allocate channel prmy2 type disk; 
  13. 4> allocate channel prmy3 type disk; 
  14. 5> allocate channel prmy4 type disk; 
  15. 6> allocate auxiliary channel stby type disk; 
  16. 7> duplicate target database for standby from active database nofilenamecheck 
  17. 8> ; 
  18. 9> } 
  19.  
  20. using target database control file instead of recovery catalog 
  21. allocated channel: prmy1 
  22. channel prmy1: SID=36 device type=DISK 
  23.  
  24. allocated channel: prmy2 
  25. channel prmy2: SID=37 device type=DISK 
  26.  
  27. allocated channel: prmy3 
  28. channel prmy3: SID=38 device type=DISK 
  29.  
  30. allocated channel: prmy4 
  31. channel prmy4: SID=39 device type=DISK 
  32.  
  33. allocated channel: stby 
  34. channel stby: SID=21 device type=DISK 
  35.  
  36. Starting Duplicate Db at 07-SEP-12 
  37.  
  38. contents of Memory Script: 
  39. { 
  40.    backup as copy reuse 
  41.    targetfile  '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwhtz' auxiliary format  
  42.  '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwhtz'   ; 
  43. } 
  44. executing Memory Script 
  45.  
  46. Starting backup at 07-SEP-12 
  47. Finished backup at 07-SEP-12 
  48.  
  49. contents of Memory Script: 
  50. { 
  51.    backup as copy current controlfile for standby auxiliary format  '/u01/app/oracle/oradata/htz/control01.ctl'; 
  52.    restore clone controlfile to  '/u01/app/oracle/oradata/htz/control02.ctl' from  
  53.  '/u01/app/oracle/oradata/htz/control01.ctl'; 
  54. } 
  55. executing Memory Script 
  56.  
  57. Starting backup at 07-SEP-12 
  58. channel prmy1: starting datafile copy 
  59. copying standby control file 
  60. output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_htz.f tag=TAG20120907T055127 RECID=1 STAMP=793345887 
  61. channel prmy1: datafile copy complete, elapsed time: 00:00:01 
  62. Finished backup at 07-SEP-12 
  63.  
  64. Starting restore at 07-SEP-12 
  65.  
  66. channel stby: copied control file copy 
  67. Finished restore at 07-SEP-12 
  68.  
  69. contents of Memory Script: 
  70. { 
  71.    sql clone 'alter database mount standby database'; 
  72. } 
  73. executing Memory Script 
  74.  
  75. sql statement: alter database mount standby database 
  76.  
  77. contents of Memory Script: 
  78. { 
  79.    set newname for tempfile  1 to  
  80.  "/u01/app/oracle/oradata/htz/temp01.dbf"; 
  81.    switch clone tempfile all; 
  82.    set newname for datafile  1 to  
  83.  "/u01/app/oracle/oradata/htz/system01.dbf"; 
  84.    set newname for datafile  2 to  
  85.  "/u01/app/oracle/oradata/htz/sysaux01.dbf"; 
  86.    set newname for datafile  3 to  
  87.  "/u01/app/oracle/oradata/htz/undotbs01.dbf"; 
  88.    set newname for datafile  4 to  
  89.  "/u01/app/oracle/oradata/htz/users01.dbf"; 
  90.    backup as copy reuse 
  91.    datafile  1 auxiliary format  
  92.  "/u01/app/oracle/oradata/htz/system01.dbf"   datafile  
  93.  2 auxiliary format  
  94.  "/u01/app/oracle/oradata/htz/sysaux01.dbf"   datafile  
  95.  3 auxiliary format  
  96.  "/u01/app/oracle/oradata/htz/undotbs01.dbf"   datafile  
  97.  4 auxiliary format  
  98.  "/u01/app/oracle/oradata/htz/users01.dbf"   ; 
  99.    sql 'alter system archive log current'; 
  100. } 
  101. executing Memory Script 
  102.  
  103. executing command: SET NEWNAME 
  104.  
  105. renamed tempfile 1 to /u01/app/oracle/oradata/htz/temp01.dbf in control file 
  106.  
  107. executing command: SET NEWNAME 
  108.  
  109. executing command: SET NEWNAME 
  110.  
  111. executing command: SET NEWNAME 
  112.  
  113. executing command: SET NEWNAME 
  114.  
  115. Starting backup at 07-SEP-12 
  116. channel prmy1: starting datafile copy 
  117. input datafile file number=00001 name=/u01/app/oracle/oradata/htz/system01.dbf 
  118. channel prmy2: starting datafile copy 
  119. input datafile file number=00002 name=/u01/app/oracle/oradata/htz/sysaux01.dbf 
  120. channel prmy3: starting datafile copy 
  121. input datafile file number=00003 name=/u01/app/oracle/oradata/htz/undotbs01.dbf 
  122. channel prmy4: starting datafile copy 
  123. input datafile file number=00004 name=/u01/app/oracle/oradata/htz/users01.dbf 
  124. output file name=/u01/app/oracle/oradata/htz/undotbs01.dbf tag=TAG20120907T055135 
  125. channel prmy3: datafile copy complete, elapsed time: 00:00:08 
  126. output file name=/u01/app/oracle/oradata/htz/users01.dbf tag=TAG20120907T055135 
  127. channel prmy4: datafile copy complete, elapsed time: 00:00:08 
  128. output file name=/u01/app/oracle/oradata/htz/sysaux01.dbf tag=TAG20120907T055135 
  129. channel prmy2: datafile copy complete, elapsed time: 00:00:56 
  130. output file name=/u01/app/oracle/oradata/htz/system01.dbf tag=TAG20120907T055135 
  131. channel prmy1: datafile copy complete, elapsed time: 00:01:06 
  132. Finished backup at 07-SEP-12 
  133.  
  134. sql statement: alter system archive log current 
  135.  
  136. contents of Memory Script: 
  137. { 
  138.    switch clone datafile all; 
  139. } 
  140. executing Memory Script 
  141.  
  142. datafile 1 switched to datafile copy 
  143. input datafile copy RECID=1 STAMP=793304890 file name=/u01/app/oracle/oradata/htz/system01.dbf 
  144. datafile 2 switched to datafile copy 
  145. input datafile copy RECID=2 STAMP=793304890 file name=/u01/app/oracle/oradata/htz/sysaux01.dbf 
  146. datafile 3 switched to datafile copy 
  147. input datafile copy RECID=3 STAMP=793304890 file name=/u01/app/oracle/oradata/htz/undotbs01.dbf 
  148. datafile 4 switched to datafile copy 
  149. input datafile copy RECID=4 STAMP=793304890 file name=/u01/app/oracle/oradata/htz/users01.dbf 
  150. Finished Duplicate Db at 07-SEP-12 
  151. released channel: prmy1 
  152. released channel: prmy2 
  153. released channel: prmy3 
  154. released channel: prmy4 
  155. released channel: stby 
  156. RMAN> exit 
  157.  
  158.  
  159. Recovery Manager complete. 

下面把备库启动到open only下面。并recover。

  1. SQL> alter database open read only; 
  2.  
  3. Database altered. 
  4.  
  5. SQL> alter database recover managed standby database using current logfile disconnect from session; 
  6.  
  7. Database altered. 
  8.  
  9.  
  10. 在alert日志中可以看到下面的内容: 
  11.  
  12. Waiting for all non-current ORLs to be archived... 
  13. All non-current ORLs have been archived. 
  14. Media Recovery Log /u01/app/oracle/arch/htz/1_6_793343515.dbf 
  15. Media Recovery Log /u01/app/oracle/arch/htz/1_7_793343515.dbf 
  16. Media Recovery Log /u01/app/oracle/arch/htz/1_8_793343515.dbf 
  17. Media Recovery Log /u01/app/oracle/arch/htz/1_9_793343515.dbf 
  18. Completed: ALTER DATABASE RECOVER  managed standby database using current logfile disconnect   
  19. Media Recovery Waiting for thread 1 sequence 10 (in transit) 
  20. Recovery of Online Redo Log: Thread 1 Group 4 Seq 10 Reading mem 0 
  21.   Mem# 0: /u01/app/oracle/oradata/htz/standby01.log 

下面就是开始测试了。这里我们是用的SCOTT这个用户来做测试,在SCOTT用户下面创建一个表,在备库去查询看是否创建成功,与在主库上面SWIRCH一次日志,看alert中的日志输出内容。

  1. 在主库上面做测试 
  2. [oracle@11g admin]$ sqlplus / as sysdba 
  3.  
  4. SQL*Plus: Release 11.2.0.2.0 Production on Fri Sep 7 05:57:41 2012 
  5.  
  6. Copyright (c) 1982, 2010, Oracle.  All rights reserved. 
  7.  
  8.  
  9. Connected to: 
  10. Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production 
  11. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  12.  
  13. SQL> alter database set standby to maximize  availability; 
  14.  
  15. Database altered. 
  16.  
  17. SQL> conn scott/tiger;  
  18. ERROR: 
  19. ORA-28000: the account is locked 
  20.  
  21.  
  22. Warning: You are no longer connected to ORACLE. 
  23. SQL> conn / as sysdba 
  24. Connected. 
  25. SQL> alter user scott identified by oracle; 
  26.  
  27. User altered. 
  28.  
  29. SQL> alter user scott account unlock; 
  30.  
  31. User altered. 
  32.  
  33. SQL> create table scott.test1 as select * from dba_objects; 
  34.  
  35. Table created. 
  36.  
  37. 备库上面 
  38.  
  39. SQL> select count(*) from scott.test1; 
  40.  
  41.   COUNT(*) 
  42. ---------- 
  43.      72391 
  44.  
  45. 说明已经同步 
  46.  
  47. 主库上面刷新日志。 
  48.  
  49. SQL> conn / as sysdba 
  50. Connected. 
  51. SQL> alter system archive log current; 
  52.  
  53. System altered. 
  54.  
  55. 日志 
  56. ALTER SYSTEM ARCHIVE LOG 
  57. Fri Sep 07 06:04:45 2012 
  58. LGWR: Standby redo logfile selected to archive thread 1 sequence 11 
  59. LGWR: Standby redo logfile selected for thread 1 sequence 11 for destination LOG_ARCHIVE_DEST_2 
  60. Thread 1 advanced to log sequence 11 (LGWR switch) 
  61.   Current log# 2 seq# 11 mem# 0: /u01/app/oracle/oradata/htz/redo02.log 
  62. Fri Sep 07 06:04:48 2012 
  63. Archived Log entry 12 added for thread 1 sequence 10 ID 0x6e285e98 dest 1: 
  64.  
  65. 备库日志 
  66.  
  67. Standby controlfile consistent with primary 
  68. RFS[5]: Selected log 5 for thread 1 sequence 11 dbid 1848107928 branch 793343515 
  69. Thu Sep 06 18:40:13 2012 
  70. Media Recovery Waiting for thread 1 sequence 11 (in transit) 
  71. Recovery of Online Redo Log: Thread 1 Group 5 Seq 11 Reading mem 0 
  72.   Mem# 0: /u01/app/oracle/oradata/htz/standby02.log 
  73. Thu Sep 06 18:40:16 2012 
  74. Archived Log entry 5 added for thread 1 sequence 10 ID 0x6e285e98 dest 1: 
  75.  
  76.  
  77.  
  78. System altered. 
linux
相关资讯       Oracle 11gR2 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款