Oracle

게시글 보기
작성자 유건데이타 등록일 2015-07-15
제목 BACKUP AND RECOVERY USING RMAN
BACKUP AND RECOVERY USING RMAN
==============================

1. Backup Method

1.1 backing up in noarchivelog mode

SVRMGR> shutdown;
SVRMGR> startup mount

rman을 가동시킨 후 다음을 수행

run {
# backup the database to disk
allocate channel dev1 type disk;
backup (database format '/oracle/backups/bp_%s_%p'); }


1.2 Backing up databases and tablespaces in archivelog mode >

- database 단위 backup script
run {
allocate channel dev1 type 'sbt_tape';
backup skip offline (database format '/oracle/backups/%d_%u');
release channel dev1;
}

- tablespace 단위 backup script
run {
allocate channel dev1 type disk;
backup
(tablespace system,tbs_1,tbs_2,tbs_3,tbs_4,tbs_5
format '/oracle/backups/bp_%s_%p');
}

- datafile 단위 backup script
run {
allocate channel dev1 type disk;
backup
(datafile '?/dbs/t_dbs1.f'
format '/oracle/backups/%d_%u');
}


- control file backup script
control file은 system datafile의 첫번째 화일을 백업받을 때 백업되며 다음과
같은 방법으로도 백업받을 수 있다.

run {
allocate channel dev1 type 'sbt_tape';
backup
(tablespace tbs_5 include current controlfile
format '%d_%u');
}

- archived logs backup script

NLS_LANG=american
NLS_DATE_FORMAT='Mon DD YYYY HH24:MI:SS'

run {
allocate channel dev1 type 'sbt_tape';
backup
(archivelog from time 'Nov 13 1996 20:57:13'
until time 'Nov 13 1996 21:06:05'
all
format '%d_%u');
}


run {
allocate channel dev1 type 'sbt_tape';
backup
(archivelog low logseq 288 high logseq 301 thread 1
all delete input
format '%d_%u');
}

- copying datafiles
run {
allocate channel dev1 type disk;
copy datafile '?/dbs/tbs_01.f/dbs/tbs_01.f' to '?/copy/temp3.f';
}

- incremental backups
새로운 데이타화일이 추가되거나 테이블스페이스가 추가된다면 level 0의 backup을
반드시 수행한다.

run {
allocate channel dev1 type 'sbt_tape';
backup incremental level 0
(database
format '%d_%u');
}

run {
allocate channel dev1 type 'sbt_tape';
backup incremental level 1
(database
format '&d_%u');
}


2. Recovery Method

- tablespace recovery

run {
allocate channel dev1 type disk;
allocate channel dev2 type 'sbt_tape';
sql "alter tablespace tbs_1 offline immediate" ;
set newname for datafile 'disk7/oracle/tbs11.f'
to 'disk9/oracle/tbs11.f' ;
restore (tablespace tbs_1) ;
switch datafile all ;
recover tablespace tbs_1 ;
sql "alter tablespace tbs_1 online" ;
release channel dev1;
release channel dev2;
}

- point-in-time recovery

TBS_1 테이블스페이스는 두 개의 데이타 화일 소유. TEMP1은 백업이 없으나 user
data는 없는 temporary segemnt만 가지고 있음.

NLS_LANG=american
NLS_DATE_FORMAT='Mon DD YYYY HH24:MI:SS'

SVRMGR> shutdown abort;
SVRMGR> startup nomount;

run {
# recover database until 3pm after restoring tbs_1 to a new location
allocate channel dev1 type disk;
allocate channel dev2 type 'sbt_tape';
set until time 'Nov 15 1996 15:00:00'
set newname for datafile '/vobs/oracle/dbs/tbs_11.f'
to '?/dbs/temp1.f' ;
set newname for datafile '?/dbs/tbs_12.f'
to '?/dbs/temp2.f' ;
restore controlfile to '/vobs/oracle/dbs/cf1.f' ;
replicate controlfile from '/vobs/oracle/dbs/cf1.f';
sql "alter database mount" ;
restore database skip tablespace temp1;
switch datafile all;
recover database skip tablespace temp1;
sql "alter database open resetlogs";
sql "drop tablespace temp1";
sql "create tablespace temp1 datafile '/vobs/oracle/dbs/temp1.f' size 10M";
release channel dev1;
release channel dev2;
}


- 전체 데이타베이스를 복구하려 할때

current redologfile이 존재할때 다음과 같은 작업으로 전체 데이타베이스를 복구할
수 있다.

replace script restore_recover_db_cf {
execute script restore_cf;
sql 'alter database mount';
execute script restore_db;
execute script recover_db;
sql 'alter database open resetlogs';
}

replace script alloc_1_disk {
allocate channel d1 type disk;
setlimit channel d1 kbytes 2097150 maxopenfiles 32 readrate 200;
}

replace script rel_1_disk {
release channel d1;
}

replace script restore_cf {
execute script alloc_1_disk;
restore
controlfile to '/private/db_files/twih/dbf/ctrl_twih_1.ctl';
replicate
controlfile from '/private/db_files/twih/dbf/ctrl_twih_1.ctl';
execute script rel_1_disk;
}

replace script restore_db {
execute script alloc_1_disk;
restore
(database);
execute script rel_1_disk;
}

replace script recover_db {
execute script alloc_1_disk;
recover
database;
execute script rel_1_disk;
}


Reference Documents
-------------------
Comment
등록된 코멘트가 없습니다.