'clonedb'에 해당되는 글 2건

  1. 2011.08.31 Clone DB를 이용한 복구
  2. 2011.08.31 Clone Database를 이용한 복구 (RMAN을 이용할 경우)
ORACLE/Backup & Recovery2011. 8. 31. 14:50
반응형
출처 : http://blog.naver.com/gseducation/20096197660

사용자 실수에 의한 장애를 Clone DB를 이용해서 복구할 수 있습니다.

관련 내용을 Eddy 블로그에 정리해 두었습니다.

 

반응형
Posted by [PineTree]
ORACLE/Backup & Recovery2011. 8. 31. 14:48
반응형
 

Clone Database를 이용한 복구 (RMAN을 이용할 경우)

 

RMAN을 이용해서 Duplicate(clone) database를 생성할 수 있다.

오라클의 매뉴얼에 자세한 순서와 설명이 있다.

 


아래 영어 설명은 매뉴얼 내용을 일부 발췌한 것이다.

  • By default, the DUPLICATE command creates the duplicate database from the most recent backups
    of the target database and then performs recovery to the most recent consistent point contained
    in the archived redo logs.

  • You can duplicate a database as it stood at a past point in time in the current incarnation,
    by using a RUN block with a SET UNTIL command, or by including an UNTIL clause with the DUPLICATE command to cause RMAN to recover the duplicate database to a past point in time within the current incarnation.

(1) Archive 모드임을 확인한 뒤에 백업을 수행한다.

 

[oracle@ora10gr2 ~]$ export ORACLE_SID=devdb
[oracle@ora10gr2 ~]$ sqlplus / as sysdba

SQL> startup force

SQL> archive log list


Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     0
Next log sequence to archive   1
Current log sequence           1

 

SQL> exit

 

[oracle@ora10gr2 ~]$ mkdir /u01/app/oracle/oradata/devdb_rman_backup
[oracle@ora10gr2 ~]$ export ORACLE_SID=devdb

[oracle@ora10gr2 ~]$ rman target /

 

RMAN> backup database format='/u01/app/oracle/oradata/devdb_rman_backup/devdb_%d_%s_%p.bus';

RMAN> exit

 

(2) 복구 완료를 확인할 테이블 생성

 

[oracle@ora10gr2 ~]$ sqlplus / as sysdba

SQL> alter system switch logfile;
SQL> alter system switch logfile;
SQL> alter system switch logfile;
SQL> alter system switch logfile;

SQL> create table phil.t2 (col1 varchar2(20));
SQL> insert into  phil.t2 values ('Recovery done!');
SQL> commit;

 

SQL> alter system switch logfile;
SQL> alter system switch logfile;

 

SQL> -- 복구의 기준이 되는 시간이므로 잘 기억하도록 한다.

SQL> !date

 

  2009. 12. 21. (월) 23:43:47 KST

 

(3) 유저 실수로 테이블이 삭제되는 상황 연출

 

SQL> alter system switch logfile;
SQL> alter system switch logfile;

SQL> -- 장애 발생
SQL> drop table phil.t2 purge;
SQL> exit

 

(4) Clone Database를 이용한 복구 시작


Task 1: Create an Oracle Password File for the Auxiliary Instance

 

[oracle@ora10gr2 ~]$ cd
[oracle@ora10gr2 ~]$ cd $ORACLE_HOME/dbs
[oracle@ora10gr2 dbs]$ orapwd file=orapwdevdbaux password=oracle entries=5

 

 Task 2: Establish Oracle Net Connectivity to the Auxiliary Instance

 

[oracle@ora10gr2 dbs]$ cd $ORACLE_HOME/network/admin
[oracle@ora10gr2 admin]$ vi tnsnames.ora

 

devdbaux =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = devdbaux)
    )
  )

 

Task 3: Create an Initialization Parameter File for the Auxiliary Instance

 

[oracle@ora10gr2 admin]$ export ORACLE_SID=devdb
[oracle@ora10gr2 admin]$ sqlplus / as sysdba

SQL> create pfile='$ORACLE_HOME/dbs/initdevdbaux.ora' from spfile;

SQL> !mkdir /u01/app/oracle/oradata/devdbaux

SQL> !vi $ORACLE_HOME/dbs/initdevdbaux.ora

 

DB_NAME=devdbaux
CONTROL_FILES='/u01/app/oracle/oradata/devdbaux/control01.ctl'
DB_FILE_NAME_CONVERT=('/u01/app/oracle/oradata/devdb', '/u01/app/oracle/oradata/devdbaux')
LOG_FILE_NAME_CONVERT=('/u01/app/oracle/oradata/devdb', '/u01/app/oracle/oradata/devdbaux')
db_block_size=4096
sga_target=200m
pga_aggregate_target=60m

 

SQL> exit

 

Task 4: Start the Auxiliary Instance

 

[oracle@ora10gr2 ~]$ export ORACLE_SID=devdbaux
[oracle@ora10gr2 ~]$ sqlplus / as sysdba
SQL> startup force nomount
SQL> exit


Task 5: Mount or Open the Target Database

 

[oracle@ora10gr2 ~]$ export ORACLE_SID=devdb
[oracle@ora10gr2 ~]$ sqlplus / as sysdba
SQL> startup force
SQL> exit

 

Task 6: Make Sure You Have the Necessary Backups and Archived Redo Logs

 

Make sure backups all target datafiles are accessible on the duplicate host.
Archived redo logs required to recover the duplicate database to the desired point in time

must be accessible at the same path by the node where the duplicate database is to be created.

 

 Task 7: Allocate Auxiliary Channels if Automatic Channels Are Not Configured

 

[oracle@ora10gr2 ~]$ export ORACLE_SID=devdbaux
[oracle@ora10gr2 ~]$ export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
[oracle@ora10gr2 ~]$ export NLS_LANG=american
[oracle@ora10gr2 ~]$ rman TARGET sys/oracle@devdb AUXILIARY /

 

RMAN> run {
 ALLOCATE AUXILIARY CHANNEL aux1 DEVICE TYPE DISK;
 DUPLICATE TARGET DATABASE TO devdbaux UNTIL TIME '2009/12/21 23:43:47';
}

 

Task 8 : 마무리

 

[oracle@ora10gr2 ~]$ export ORACLE_SID=devdbaux
[oracle@ora10gr2 dbs]$ sqlplus / as sysdba

SQL> select * from phil.t2;

 

COL1
--------------------
Recovery done!


SQL> !exp phil/phil file=t2.dmp tables=t2
SQL> exit

 

[oracle@ora10gr2 dbs]$ export ORACLE_SID=devdb
[oracle@ora10gr2 dbs]$ sqlplus phil/phil

SQL> select * from t2;

 

select * from t2
              *
ERROR at line 1:
ORA-00942: table or view does not exist

 

SQL> !imp phil/phil file=t2.dmp tables=t2
SQL> select * from t2;

 

COL1
--------------------
Recovery done!

 

 

____________________________________________________________________________________________________________________

 

참고1.


A duplicate database is a copy of a target database

that you can run independently for a variety of purposes.

 

For example, you can use it to:

 

  - Test backup and recovery procedures

  - Export data such as a table that was inadvertently dropped from the production database,

    and then import it back into the production database

 

참고2.

 

As part of the duplicating operation, RMAN automates the following steps:

 

 - Creates a control file for the duplicate database

 - Restores the target datafiles to the duplicate database and performs incomplete recovery

   by using all available incremental backups and archived redo logs

 - Shuts down and starts the auxiliary instance

 - Opens the duplicate database with the RESETLOGS option after incomplete recovery

    to create the online redo logs (except when running DUPLICATE ... FOR STANDBY,

    in which case RMAN does not open the database)

 - Generates a new, unique DBID for the duplicate database (except when you create a standby database

   with DUPLICATE ... FOR STANDBY, in which case RMAN does not create a unique DBID)

 

During duplication, RMAN must perform incomplete recovery because the online redo logs in the target are not backed up and cannot be applied to the duplicate database. The farthest that RMAN can go in recovery of the duplicate database is the most recent redo log archived by the target database.

반응형
Posted by [PineTree]