RAC 简单归档设置下备份恢复理解


理解最简单的备份方法,理解rman是如何备份与恢复的。
集群环境下对归档日志的备份注意事项:
必须保证备份实例上能够访问所有实例的归档日志,否则会报错,除非为各个实例分配通道。

集群环境下恢复注意事项:
进行restore时,为每个实例配置通道,以正确的转储。
进行recover时,当前操作实例必须能够访问所有的归档日志文件,否则可能恢复失败。

以上注意事项在任何归档日志设置情况下成立,只是有些情况下Oracle为我们做了,或通过asm,或通过nfs,或其它方式。


以下以 最简单的归档日志设置 为例进行测试,
alter system set log_archive_dest_1='LOCATION=/oracle/rac1_arch' scope=spfile sid='RACDB1';
alter system set log_archive_dest_1='LOCATION=/oracle/rac2_arch' scope=spfile sid='RACDB2';

备份过程:

[plain]
  1. RACDB1@rac1 /home/oracle$ rman target /  
  2.   
  3. Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 11 23:52:28 2012  
  4.   
  5. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  6.   
  7. connected to target database: RACDB (DBID=769091368)  
  8.   
  9. RMAN> backup archivelog all tag='arc_bak' format='/oracle/backup/arch_%U_%T';  
  10.   
  11. Starting backup at 11-JAN-12  
  12. current log archived  
  13. using target database control file instead of recovery catalog  
  14. allocated channel: ORA_DISK_1  
  15. channel ORA_DISK_1: sid=152 instance=RACDB1 devtype=DISK  
  16. RMAN-00571: ===========================================================  
  17. RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============  
  18. RMAN-00571: ===========================================================  
  19. RMAN-03002: failure of backup command at 01/11/2012 23:52:54  
  20. RMAN-06059: expected archived log not found, lost of archived log compromises recoverability  
  21. ORA-19625: error identifying file /oracle/rac2_arch/2_11_771474603.dbf  
  22. ORA-27037: unable to obtain file status  
  23. Linux Error: 2: No such file or directory  
  24. Additional information: 3  
  25.   
  26. RMAN> quit  
  27.   
  28.   
  29. Recovery Manager complete.  
  30.   
  31. ORA-19625: error identifying file /oracle/rac2_arch/2_11_771474603.dbf   
ORA-19625: error identifying file /oracle/rac2_arch/2_11_771474603.dbf
找不到2_11_771474603.dbf 这个归档日志文件,因为在本地/oracle/rac2_arch/目录没有这个文件。这个文件在节点二的本地/oracle/rac2_arch/目录下,看下面:

[plain]
  1. RACDB1@rac1 /home/oracle$ ll /oracle/rac2_arch/  
  2. total 0  
  3. RACDB1@rac1 /home/oracle$ ssh rac2  
  4. Last login: Wed Jan 11 23:50:52 2012 from rac1  
  5. RACDB2@rac2 /home/oracle$ ll /oracle/rac1_arch/  
  6. total 0  
  7. RACDB2@rac2 /home/oracle$ ll /oracle/rac2_arch/  
  8. total 132  
  9. -rw-rw---- 1 oracle oinstall 95744 Jan 11 23:51 2_11_771474603.dbf   --就是无法找到这个日志文件  
  10. -rw-rw---- 1 oracle oinstall 32768 Jan 11 23:52 2_12_771474603.dbf  
采用connect的方法来分配通道,可以成功备份。

[plain]
  1. RACDB1@rac1 /home/oracle$ rman target /  
  2.   
  3. Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jan 12 00:31:16 2012  
  4.   
  5. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  6.   
  7. connected to target database: RACDB (DBID=769091368)  
  8.   
  9. RMAN>  run  
  10. 2>  {  
  11. 3>  allocate channel c1 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb1;  
  12.  allocate channel c2 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb2;  
  13. 5>  backup archivelog all tag='arc_bak' ;  
  14. 6>  release channel c1;  
  15. 7>  release channel c2;  
  16. 8>  }  
  17.   
  18. using target database control file instead of recovery catalog  
  19. allocated channel: c1  
  20. channel c1: sid=131 instance=RACDB1 devtype=DISK  
  21.   
  22. allocated channel: c2  
  23. channel c2: sid=147 instance=RACDB2 devtype=DISK  
  24.   
  25. Starting backup at 12-JAN-12  
  26. current log archived  
  27. ......  
  28. ......  
  29. piece handle=/oracle/backup/arch_08n0hm06_1_1_20120112 tag=ARC_BAK comment=NONE  
  30. channel c2: backup set complete, elapsed time: 00:00:03  
  31. Finished backup at 12-JAN-12  
  32.   
  33. released channel: c1  
  34.   
  35. released channel: c2  
  36.   
  37. RMAN> quit  
  38.   
  39.   
  40. Recovery Manager complete.  
  41.   
  42. --查看两个节点的备份结果  
  43. RACDB1@rac1 /home/oracle$ ll /oracle/backup/  
  44. total 159996  
  45. -rw-r----- 1 oracle oinstall 123994112 Jan 12 00:31 arch_05n0hlvp_1_1_20120112  
  46. -rw-r----- 1 oracle oinstall  39667712 Jan 12 00:32 arch_07n0hm05_1_1_20120112  
  47. RACDB1@rac1 /home/oracle$ su rac2  
  48. su: user rac2 does not exist  
  49. RACDB1@rac1 /home/oracle$ ssh rac2  
  50. Last login: Thu Jan 12 00:27:36 2012 from rac1  
  51. RACDB2@rac2 /home/oracle$ ll /oracle/backup/  
  52. total 73252  
  53. -rw-r----- 1 oracle oinstall 73526784 Jan 12 00:32 arch_06n0hlvp_1_1_20120112  
  54. -rw-r----- 1 oracle oinstall  1399296 Jan 12 00:32 arch_08n0hm06_1_1_20120112  

恢复过程:
 --全备数据库
 --分别在两个节点构造数据后,备份所有归档日志
 --关闭数据库后,在asmcmd下删除一数据文件
 --使用归档日志实施数据文件的恢复.(备份中没有对此数据文件的备份)
 
 归档日志设置:
 alter system set log_archive_dest_1='LOCATION=/oracle/rac1_arch' scope=spfile sid='RACDB1';
 alter system set log_archive_dest_1='LOCATION=/oracle/rac2_arch' scope=spfile sid='RACDB2';

[plain] --首先全备数据库  
  1. BACKUP FORMAT '/oracle/backup/racdb_%U_%T' DATABASE TAG racdb_hot_db_bk;   
[plain]
  1. --两个节点构造数据   
  2. RACDB1@rac1 /home/oracle$ sqlplus lau/lau@racdb1  
  3.   
  4. SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 11 22:54:44 2012  
  5.   
  6. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  7.   
  8.   
  9. Connected to:  
  10. Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production  
  11. With the Partitioning, Real Application Clusters, OLAP and Data Mining options  
  12.   
  13. SQL> select name from v$datafile;  
  14.   
  15. NAME  
  16. --------------------------------------------------------------------------------  
  17. +DATA/racdb/datafile/system.256.771474531  
  18. +DATA/racdb/datafile/undotbs1.258.771474533  
  19. +DATA/racdb/datafile/sysaux.257.771474533  
  20. +DATA/racdb/datafile/users.259.771474535  
  21. +DATA/racdb/datafile/example.264.771474649  
  22. +DATA/racdb/datafile/undotbs2.265.771474825  
  23.   
  24. 6 rows selected.  
  25.   
  26. SQL> create tablespace test;  
  27.   
  28. Tablespace created.  
  29.   
  30. SQL> select name from v$datafile;  
  31.   
  32. NAME  
  33. --------------------------------------------------------------------------------  
  34. +DATA/racdb/datafile/system.256.771474531  
  35. +DATA/racdb/datafile/undotbs1.258.771474533  
  36. +DATA/racdb/datafile/sysaux.257.771474533  
  37. +DATA/racdb/datafile/users.259.771474535  
  38. +DATA/racdb/datafile/example.264.771474649  
  39. +DATA/racdb/datafile/undotbs2.265.771474825  
  40. +DATA/racdb/datafile/test.283.772321119  
  41.   
  42. 7 rows selected.  
  43.   
  44. SQL> create table t(id int,text varchar2(10)) tablespace test;  
  45.   
  46. Table created.  
  47.   
  48. SQL> insert into t values(1,'hello');  
  49.   
  50. 1 row created.  
  51.   
  52. SQL> commit;  
  53.   
  54. Commit complete.  
  55.   
  56. SQL> alter system switch logfile;  
  57.   
  58. System altered.  
  59.   
  60. SQL> quit  
  61. Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production  
  62. With the Partitioning, Real Application Clusters, OLAP and Data Mining options  
  63. RACDB1@rac1 /home/oracle$ ssh rac2  
  64. Last login: Wed Jan 11 21:29:25 2012 from rac1  
  65. RACDB2@rac2 /home/oracle$ sqlplus lau/lau@racdb2  
  66.   
  67. SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 11 21:41:51 2012  
  68.   
  69. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  70.   
  71.   
  72. Connected to:  
  73. Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production  
  74. With the Partitioning, Real Application Clusters, OLAP and Data Mining options  
  75.   
  76. SQL> insert into t values(2,'world');  
  77.   
  78. 1 row created.  
  79.   
  80. SQL> commit;  
  81.   
  82. Commit complete.  
  83.   
  84. SQL> alter system switch logfile;  
  85.   
  86. System altered.  
  87.   
  88. SQL> quit  
  89. Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production  
  90. With the Partitioning, Real Application Clusters, OLAP and Data Mining options  
  91.   
  92. --查看两个节点的归档日志  
  93. RACDB2@rac2 /home/oracle$ ll /oracle/rac2_arch/  
  94. total 1052  
  95. -rw-r----- 1 oracle oinstall 1070592 Jan 11 21:42 2_8_771474603.dbf  
  96. RACDB2@rac2 /home/oracle$ ssh rac1  
  97. Last login: Wed Jan 11 21:29:21 2012 from 192.168.246.1  
  98. RACDB1@rac1 /home/oracle$ ll /oracle/rac1_arch/  
  99. total 26876  
  100. -rw-r----- 1 oracle oinstall 27486720 Jan 11 21:41 1_9_771474603.dbf  
  101. RACDB1@rac1 /home/oracle$ ssh rac2  
  102. Last login: Wed Jan 11 21:41:31 2012 from rac1  
  103. RACDB2@rac2 /home/oracle$ ll /oracle/backup/  
  104. total 0  
  105.   
  106. --全备归档日志  
  107. RACDB2@rac2 /home/oracle$ ssh rac1  
  108. Last login: Wed Jan 11 21:42:49 2012 from rac2  
  109. RACDB1@rac1 /home/oracle$ rman target /  
  110.   
  111. Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 11 21:43:47 2012  
  112.   
  113. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  114.   
  115. connected to target database: RACDB (DBID=769091368)  
  116.   
  117. run  
  118.  {  
  119.  allocate channel c1 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb1;  
  120.  allocate channel c2 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb2;  
  121.  backup archivelog all delete all input;  
  122.  release channel c1;  
  123.  release channel c2;  
  124. 8>  }  
  125.   
  126. using target database control file instead of recovery catalog  
  127. allocated channel: c1  
  128. channel c1: sid=141 instance=RACDB1 devtype=DISK  
  129.   
  130. allocated channel: c2  
  131. channel c2: sid=124 instance=RACDB2 devtype=DISK  
  132.   
  133. Starting backup at 11-JAN-12  
  134. current log archived  
  135. ......  
  136. ......  
  137. channel c1: deleting archive log(s)  
  138. archive log filename=/oracle/rac1_arch/1_9_771474603.dbf recid=15 stamp=772321287  
  139. archive log filename=/oracle/rac1_arch/1_10_771474603.dbf recid=17 stamp=772321478  
  140. Finished backup at 11-JAN-12  
  141.   
  142. released channel: c1  
  143.   
  144. released channel: c2  
  145.   
  146. RMAN> quit  
  147.   
  148.   
  149. Recovery Manager complete.  
  • 1
  • 2
  • 下一页

相关内容