Dataguard環境でのバックアップとリカバリ


Active data guardの導入後、読み取り専用のクエリーをバックアップに渡すだけでなく、日常のデータベースバックアップ作業をバックアップに置いて実行することで、プライマリ・ライブラリの圧力を軽減し、サーバ・リソースを十分に発揮します.次に、バックアップを利用してプライマリ・ライブラリのデータを復元するプロセスを示します.
一:メインライブラリに表領域を作成し、表領域に表を作成し、テストデータを挿入し、同時に予備ライブラリの同期状況を検査する
   
   
   
   
  1. SQL> create tablespace test01 datafile '/u01/app/oracle/oradata/db1/test01.dbf' size 10M;
    Tablespace created.
  2. SQL> create table rman tablespace test01 as select object_id,object_name from dba_objects;  
  3. Table created.  
  4.  
  5. SQL> select count(*) from rman;  
  6.  
  7.   COUNT(*)  
  8. ----------  
  9.      76379  
  10.  
  11. [oracle@db2 db1]$ sqlplus  /nolog  
  12. SQL*Plus: Release 11.2.0.3.0 Production on Mon Oct 29 11:37:38 2012  
  13. Copyright (c) 1982, 2011, Oracle.  All rights reserved.  
  14.  
  15. SQL> conn /as sysdba  
  16. Connected.  
  17. SQL> select count(*) from rman;  
  18.  
  19.   COUNT(*)  
  20. ----------  
  21.      76379 

二:リポジトリ上でrmanを使用して新しい表領域test 01をバックアップする
   
   
   
   
  1. [oracle@db2 db1]$ rman target /  
  2. Recovery Manager: Release 11.2.0.3.0 - Production on Mon Oct 29 11:38:01 2012  
  3. Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.  
  4. connected to target database: DB1 (DBID=1387827106)  
  5.  
  6. RMAN> report schema;  
  7.  
  8. RMAN> backup tablespace test01 format '/home/oracle/test01_%U';  
  9.  
  10. Starting backup at 2012-10-29-11:38:50  
  11. allocated channel: ORA_DISK_1  
  12. channel ORA_DISK_1: SID=1 device type=DISK 
  13. channel ORA_DISK_1: starting full datafile backup set  
  14. channel ORA_DISK_1: specifying datafile(s) in backup set  
  15. input datafile file number=00034 name=/u01/app/oracle/oradata/db1/test01.dbf  
  16. channel ORA_DISK_1: starting piece 1 at 2012-10-29-11:38:51  
  17. channel ORA_DISK_1: finished piece 1 at 2012-10-29-11:38:52  
  18. piece handle=/home/oracle/test01_03novc2b_1_1 tag=TAG20121029T113851 comment=NONE 
  19. channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01  
  20. Finished backup at 2012-10-29-11:38:52 

三:メインライブラリを閉じた後、表領域データファイルを削除し、データ損失シーンをシミュレートする
   
   
   
   
  1. [oracle@db1 ~]$ sqlplus /nolog  
  2. SQL*Plus: Release 11.2.0.3.0 Production on Mon Oct 29 11:39:49 2012  
  3. Copyright (c) 1982, 2011, Oracle.  All rights reserved.  
  4.  
  5. SQL> conn /as sysdba  
  6. Connected.  
  7. SQL> shutdown immediate  
  8. Database closed.  
  9. Database dismounted.  
  10. ORACLE instance shut down.  
  11. SQL> exit  
  12.  
  13. [oracle@db1 ~]$ rm -rf /u01/app/oracle/oradata/db1/test01.dbf  

四:メインライブラリを再起動し、mount状態にしか起動できない
   
   
   
   
  1. [oracle@db1 ~]$ sqlplus  /nolog  
  2. SQL*Plus: Release 11.2.0.3.0 Production on Mon Oct 29 11:41:42 2012  
  3. Copyright (c) 1982, 2011, Oracle.  All rights reserved.  
  4. SQL> conn /as sysdba  
  5. Connected to an idle instance.  
  6. SQL> startup  
  7. ORACLE instance started.  
  8.  
  9. Total System Global Area 1536602112 bytes  
  10. Fixed Size                  2228624 bytes  
  11. Variable Size            1174408816 bytes  
  12. Database Buffers          352321536 bytes  
  13. Redo Buffers                7643136 bytes  
  14. Database mounted.  
  15. ORA-01157: cannot identify/lock data file 34 - see DBWR trace file  
  16. ORA-01110: data file 34: '/u01/app/oracle/oradata/db1/test01.dbf'  
  17.  
  18. SQL> select open_mode,database_role from v$database;  
  19.  
  20. OPEN_MODE            DATABASE_ROLE  
  21. -------------------- ----------------  
  22. MOUNTED              PRIMARY 

五:予備ライブラリのバックアップデータをメインライブラリにコピーし、catalogコマンドを使用してメインライブラリの制御ファイルに登録する
   
   
   
   
  1. [oracle@db2 ~]$ scp test01_03novc2b_1_1 db1:/home/oracle/  
  2. [oracle@db1 ~]$ rman target /  
  3. Recovery Manager: Release 11.2.0.3.0 - Production on Mon Oct 29 11:45:02 2012  
  4. Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.  
  5. connected to target database: DB1 (DBID=1387827106, not open)  
  6.  
  7. RMAN> list backup of tablespace test01;  
  8. specification does not match any backup in the repository  
  9.  
  10. RMAN>  catalog backuppiece '/home/oracle/test01_03novc2b_1_1';  
  11.  
  12. cataloged backup piece  
  13. backup piece handle=/home/oracle/test01_03novc2b_1_1 RECID=42 STAMP=797946436 
  14.  
  15. RMAN> list backup of tablespace test01;  
  16.  
  17. List of Backup Sets 
  18. ===================  
  19.  
  20. BS Key  Type LV Size       Device Type Elapsed Time Completion Time      
  21. ------- ---- -- ---------- ----------- ------------ -------------------  
  22. 42      Full    3.98M      DISK        00:00:00     2012-10-29-11:38:51  
  23.         BP Key: 42   Status: AVAILABLE  Compressed: NO  Tag: TAG20121029T113851  
  24.         Piece Name: /home/oracle/test01_03novc2b_1_1  
  25.   List of Datafiles in backup set 42  
  26.   File LV Type Ckp SCN    Ckp Time            Name  
  27.   ---- -- ---- ---------- ------------------- ----  
  28.   34      Full 10350465   2012-10-29-11:35:32 /u01/app/oracle/oradata/db1/test01.dbf 

六:表領域test 01を復元して復元し、メインライブラリを読み書き状態に起動し、メインバックアップデータのリアルタイム同期状況をテストする
   
   
   
   
  1. RMAN> restore tablespace test01;  
  2. Starting restore at 2012-10-29-11:47:50  
  3. allocated channel: ORA_DISK_1  
  4. channel ORA_DISK_1: SID=21 device type=DISK 
  5.  
  6. channel ORA_DISK_1: starting datafile backup set restore  
  7. channel ORA_DISK_1: specifying datafile(s) to restore from backup set  
  8. channel ORA_DISK_1: restoring datafile 00034 to /u01/app/oracle/oradata/db1/test01.dbf  
  9. channel ORA_DISK_1: reading from backup piece /home/oracle/test01_03novc2b_1_1  
  10. channel ORA_DISK_1: piece handle=/home/oracle/test01_03novc2b_1_1 tag=TAG20121029T113851 
  11. channel ORA_DISK_1: restored backup piece 1  
  12. channel ORA_DISK_1: restore complete, elapsed time: 00:00:01  
  13. Finished restore at 2012-10-29-11:47:52  
  14.  
  15. RMAN> recover tablespace test01;  
  16. Starting recover at 2012-10-29-11:48:02  
  17. using channel ORA_DISK_1  
  18.  
  19. starting media recovery  
  20. media recovery complete, elapsed time: 00:00:01  
  21.  
  22. Finished recover at 2012-10-29-11:48:03  
  23.  
  24. RMAN> alter database open;  
  25. database opened  
  26.  
  27. [oracle@db1 ~]$ sqlplus  /nolog  
  28. SQL*Plus: Release 11.2.0.3.0 Production on Mon Oct 29 11:48:47 2012  
  29. Copyright (c) 1982, 2011, Oracle.  All rights reserved.  
  30.  
  31. SQL> conn /as sysdba  
  32. Connected.  
  33. SQL> truncate table rman;  
  34. Table truncated.  
  35.  
  36. [oracle@db2 ~]$ sqlplus  /nolog  
  37. SQL*Plus: Release 11.2.0.3.0 Production on Mon Oct 29 11:49:12 2012  
  38. Copyright (c) 1982, 2011, Oracle.  All rights reserved.  
  39.  
  40. SQL> conn /as sysdba  
  41. Connected.  
  42. SQL> select count(*) from rman;  
  43.  
  44.   COUNT(*)  
  45. ----------  
  46.          0